Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- New configuration for buffer sizes (#58)
### Changed
### Fixed
### Docs
Expand All @@ -17,9 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for non-browsers by implementing server initiated heartbeats (#39)
- Start new ct-watchers as new ct logs become available (#42)
- More logging to document currently watched logs (03d878e)

### Changed
- Changed log output to be better grepable (5c055cc)
- Update ct log update interval to once per hour instead of once per 6 hours as previously (9b6e77d)

### Fixed
- Fixed a possible race condition when accessing metrics

Expand Down
9 changes: 9 additions & 0 deletions config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ general:
- url: https://dodo.ct.comodo.com/
operator: "Comodo"
description: "Comodo Dodo"
# To optimize the performance of the server, you can overwrite the size of different buffers
# For low CPU, low memory machines, you should reduce the buffer sizes to save memory in case the CPU is maxed.
buffer_sizes:
# Buffer for each websocket connection
websocket: 300
# Buffer for each CT log connection
ctlog: 1000
# Combined buffer for the broadcast manager
broadcastmanager: 10000
2 changes: 1 addition & 1 deletion internal/certificatetransparency/ct-watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (w *worker) runWorker(ctx context.Context) error {
Matcher: scanner.MatchAll{},
PrecertOnly: false,
NumWorkers: 1,
BufferSize: 1000,
BufferSize: config.AppConfig.General.BufferSizes.CTLog,
})

scanErr := certScanner.Scan(ctx, w.foundCertCallback, w.foundPrecertCallback)
Expand Down
19 changes: 19 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ type LogConfig struct {
Description string `yaml:"description"`
}

type BufferSizes struct {
Websocket int `yaml:"websocket"`
CTLog int `yaml:"ctlog"`
BroadcastManager int `yaml:"broadcastmanager"`
}

type Config struct {
Webserver struct {
ServerConfig `yaml:",inline"`
Expand All @@ -47,6 +53,7 @@ type Config struct {
}
General struct {
AdditionalLogs []LogConfig `yaml:"additional_logs"`
BufferSizes BufferSizes `yaml:"buffer_sizes"`
}
}

Expand Down Expand Up @@ -211,5 +218,17 @@ func validateConfig(config *Config) bool {

config.General.AdditionalLogs = validLogs

if config.General.BufferSizes.Websocket <= 0 {
config.General.BufferSizes.Websocket = 300
}

if config.General.BufferSizes.CTLog <= 0 {
config.General.BufferSizes.CTLog = 1000
}

if config.General.BufferSizes.BroadcastManager <= 0 {
config.General.BufferSizes.BroadcastManager = 10000
}

return true
}
4 changes: 2 additions & 2 deletions internal/web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func upgradeConnection(w http.ResponseWriter, r *http.Request) (*websocket.Conn,

// setupClient initializes a client struct and starts the broadcastHandler and websocket listener.
func setupClient(connection *websocket.Conn, subscriptionType SubscriptionType, name string) {
c := newClient(connection, subscriptionType, name, 300)
c := newClient(connection, subscriptionType, name, config.AppConfig.General.BufferSizes.Websocket)
go c.broadcastHandler()
go c.listenWebsocket()

Expand Down Expand Up @@ -275,7 +275,7 @@ func NewWebsocketServer(networkIf string, port int, certPath, keyPath string) *W
setupWebsocketRoutes(server.routes)
server.initServer()

ClientHandler.Broadcast = make(chan models.Entry, 10_000)
ClientHandler.Broadcast = make(chan models.Entry, config.AppConfig.General.BufferSizes.BroadcastManager)
go ClientHandler.broadcaster()

return server
Expand Down