From my understanding, django user sessions are stored in the database and not in the memory’s server. If that is true, I think that if I built an api with django it would be stateless. Therefore, I can scale my api horizontally. Is that correct or am I missing something? If I’m missing something, how can I make django scale horizontally?
You’re not missing anything. In fact, if you’re running Django within uwsgi, it’s already doing that for you in a single-server environment.
You do not have to store your user sessions in the database. Personal taste, but sessions are transient and are not really made to be stored in your database.
In addition, this might become a problem when running master/slave(s) topology and the slave(s) are (even a few hundredths of a second) late in the replication (assuming 100% of the database is replicated of course).
Other solutions include:
. client-side cookie
Very possible and very easy as Ken mentioned. I’ve been running Django projects behind load balancers for while but it’s also why you can run Django in a serverless setup using something like Zappa GitHub - zappa/Zappa: Serverless Python