Skip to main content
When using a dedicated deployment, it is important to optimize the client-side HTTP connection pooling for maximum performance. We recommend using our Python SDK as it has good defaults for connection pooling and utilizes httpx for optimal performance with Python’s asyncio library. It also includes retry logic for handling 429 errors that Fireworks returns when the server is overloaded.

General optimization recommendations

Based on our benchmarks, we recommend the following:
  1. Use a client library optimized for high concurrency, such as httpx in Python or http.Agent in Node.js.
  2. Use the AsyncFireworks client for high-concurrency workloads.
  3. Increase concurrency until performance stops improving or you observe too many 429 errors.

Code example: Optimal concurrent requests (Python)

Install the Fireworks Python SDK:
The SDK is currently in alpha. Use the --pre flag when installing to get the latest version.
Here’s how to implement optimal concurrent requests using asyncio and the AsyncFireworks client:
main.py
This implementation:
  • Uses AsyncFireworks for non-blocking async requests with optimized connection pooling
  • Uses asyncio.Semaphore to control concurrency to avoid overwhelming the server