Django SaaS multi-tenancy(?) architecture

Hey there!

I started with Django a few months ago and I‘d like to try and build something I already have as SaaS application.
The Python script I have reads an API, does some number crunching on the results and sends calls to another API accordingly (mostly notifications via a Telegram bot).
The Telegram bot token as well as some other configurations are pulled off of a settings file that is user specific.

Now, translating this to a Django Project - I have little to no experience with the architecture of such a service.

What I want to achieve:

  • User can register / log in
  • User can enter settings / info and they get saved
  • every user gets their telegram notifications according to their settings
  • the benefit of one central code base, not having to send out new versions of the script to the 5-10 users it has

What I don’t understand right now:

  • How do I manage and monitor the processes in the background?
  • What are best practices to write such a thing in a pythonic way and with limited server side resources in mind?
  • What precautions can I consider so that this could scale to 100 or 1000 users instead of 5-10?

Thanks in advance for your time!

Franz

P.S.: “(?)” in the title because I read up on the topic of multi tenancy but am not sure if it is what I need :smile:

You’ve a couple of big issues going on in your question. It looks like you need:

  • User account management
  • Background task handling

For user accounts, check out the User authentication in Django guide. That should introduce you to the default tools that Django has for user management.

Background task handling is a trickier subject. There are a variety of tools that can run code in the background and on a schedule. Common choices include:

My experience with background tasks is limited to Celery. It’s a solid tool, but it requires a fair amount of setup. I’ve heard Redis Queue is a pretty good option that is lighter weight, but I’d have to defer to others with actual experience using it.

Thank you for pointing those out! This already helped a lot.

Do you happen to have some go-to references / tutorials on Celery?

The Celery documentation is pretty good. http://docs.celeryproject.org/en/latest/getting-started/index.html

1 Like