Issue
As we self-host Appsmith on AWS ECS, we have a single container that runs Appsmith. However, as our user base grows, we need to scale CPU and Memory horizontally. The problem is that user sessions are not shared between containers, which could be due to a lack of a common data store. How can we achieve this in ECS or any containerized environment?
Resolution
The solution to achieving shared user sessions between containers in a containerized environment such as AWS ECS is to use a common data store for session management. This involves storing the session data in a central location that all containers have access to. The most common approach to achieving this is by using a shared cache such as Memcached or Redis.
In order to set this up, you would need to configure your application to use a shared cache for session management. You could explore using a containerized cache instance like Redis or Memcached and link it to your Appsmith container through Docker Compose. Alternatively, you could choose to use a managed cache service like Amazon ElastiCache, which provides a fully managed Redis or Memcached cache service that can be easily integrated with your ECS deployment.
Once you have set up the shared cache, you can configure your Appsmith container to use it for session management. This would typically involve modifying the application code to use a session store provided by the shared cache service.
Overall, the key is to ensure that all containers have access to the shared cache so that user sessions can be shared across all instances of the application. This will enable horizontal scaling of CPU and memory in your AWS ECS deployment without risking loss of session data.