Case study: AI sales, performance
Cutting API response time by 60% on an AI sales platform
Migrated an AI sales-agent platform from synchronous request handling to async services and an async database layer, reducing API response time by 60%.
- Client
- An AI sales platform, name withheld
- My role
- Senior Software Engineer
- Engagement
- Delivered through Torch Solutions
I worked on this as a Senior Software Engineer at Torch Solutions, the engineering firm contracted by the client. The product belongs to the client.
Project overview
The product is a conversational sales agent. It answers inbound questions from prospects and connects qualified leads to a sales representative.
The platform was in production and its API had become slow. I led the work to modernize how the backend handles requests.
The business problem
A sales conversation that waits on the server loses the prospect. The API was handling requests synchronously, and response times showed it.
Slow responses in a live conversation
Every reply from the agent depends on API calls completing quickly.
Blocking work on every request
With synchronous handling, each request holds a worker for the full duration of its model and database calls.
My role and responsibilities
Engineering lead for the migration, on a platform that had to stay available while it changed.
- Planned the move from synchronous request handling to async services
- Replaced the database layer with an async one
- Carried the change through to production
Technical challenges
Changing the request path of a live system
The platform was already serving conversations, so the migration had to happen without breaking them.
Async has to go all the way down
An async endpoint that calls a blocking database driver is still blocking. The data layer had to move with the services.
Solution and implementation
A production migration to async services and an async database layer, so time spent waiting on models and the database no longer blocks other requests.
Async services
Request handling moved to async Python on FastAPI, so the API can serve other requests while one waits on a language model.
Async database layer
Database access moved to an async layer on PostgreSQL, removing the blocking calls that remained in the request path.
Technology stack
- Backend
- Python, FastAPI, async Python
- Data
- PostgreSQL
- AI
- LLM pipelines
Outcomes
Only results that are documented are listed here.
- API response time reduced by 60%
- Synchronous request handling replaced with async services in production
Lessons learned
- In LLM products, latency is usually a systems problem before it is a model problem.
- A partial async migration gives partial results. The slowest blocking call sets the pace.
- Measure the request path before and after. A number is what makes the work worth it to the business.
Related services
- AI Product Development: Taking an AI product from idea or prototype to production-ready software: architecture, backend, frontend, integrations, testing and deployment.
More case studies
Working on something similar?
If your product has the same kind of constraints, I am glad to talk through how I would approach it.
Or email sarmadkhalique001@gmail.com