Optimizing Bifrost’s memory usage and performance for your specific workload.
Concurrency (concurrency)
: Controls the number of simultaneous requests to each provider.Request Buffering (buffer_size)
: Defines the queue size for pending requests for each
provider.Object Pooling (initial_pool_size)
: Pre-allocates memory for request/response objects to
reduce garbage collection overhead.concurrency
)ProviderConfig
returned by your Account
implementation.
config.json
under each provider’s concurrency_and_buffer_size
.
buffer_size
)dropExcessRequests
: If the buffer is full, the behavior depends on the global
dropExcessRequests
setting (Go package only).
false
(default): New requests will block until space is available in the queue.true
: New requests are immediately dropped with an error.ProviderConfig
.
config.json
. Note that dropExcessRequests
is not configurable
for the HTTP transport and defaults to false
(blocking).
initial_pool_size
)BifrostConfig
.
For the HTTP transport, it’s configured via command-line flags or environment variables, not in
config.json
.InitialPoolSize
in the BifrostConfig
during initialization.
-pool-size
command-line flag.
APP_POOL_SIZE
environment variable.
Note: This feature is under active development.A planned feature for Bifrost is dynamic scaling, which will allow
concurrency
and buffer_size
to adjust automatically based on real-time request load and provider feedback (like rate-limit
headers). This will enable Bifrost to smartly self-tune for optimal performance and cost-efficiency.
Use Case | Concurrency (per provider) | Buffer Size (per provider) | Initial Pool Size (global) | Goal |
---|---|---|---|---|
🚀 High-Throughput | 50-200 | 500-1000 | 1000-5000 | Maximize RPS, assuming provider rate limits are high. |
⚖️ Balanced (Default) | 10-50 | 100-500 | 500-1000 | Good for most production workloads with moderate traffic. |
💧 Burst-Resistant | 10-20 | 1000-5000 | 500-1000 | Handles sudden traffic spikes without dropping requests. |
🌱 Resource-Constrained | 2-5 | 10-50 | 50-100 | Minimizes memory footprint for development or low-traffic services. |
/metrics
endpoint. While
there are no specific memory metrics, you can monitor go_memstats_*
to observe memory usage.net/http/pprof
tool to inspect heap allocations and goroutine counts.💡 Tip: Start with the Balanced configuration and adjust based on observed performance and resource utilization. For example, if you see requests blocking frequently, increasebuffer_size
. If your provider rate limits are being hit, decreaseconcurrency
.