The Gateway is currently implemented as a FastAPI server, but most of its external interactions are synchronous. Even though suboptimal, this approach worked while the Gateway was simply a thin layer taking care of quick admin operations like registering tasks for execution. With the introduction of the serverless functionality, however, the Gateway can quickly become the bottleneck under load, while multiple requests wait for models to be deployed (a synchronous operation by design, meaning that requests don't return until a container has been created to handle them). Now, we should look into making the Gateway fully async, focusing on the following interactions:
The Gateway is currently implemented as a FastAPI server, but most of its external interactions are synchronous. Even though suboptimal, this approach worked while the Gateway was simply a thin layer taking care of quick admin operations like registering tasks for execution. With the introduction of the serverless functionality, however, the Gateway can quickly become the bottleneck under load, while multiple requests wait for models to be deployed (a synchronous operation by design, meaning that requests don't return until a container has been created to handle them). Now, we should look into making the Gateway fully async, focusing on the following interactions:
Postgres
asynciointegrationasyncpgandaiosqliteto support both production and development workflowsMinIO
aiobotocore, an async-compatible port of the core library behindboto3, the official AWS client for managing AWS resourcesRabbitMQ
pikawithBlockingConnectionto manage our queue. We should explore transitioning to theAsyncioConnectionadapter, looking into different libraries (e.g.aio-pika) if that's not enoughCMS healthcheck and
/infocallshttpxwhich we already use for the auto deployment feature