This post has been more than 4 years since it was last updated.
Industry trends like the shift from monolith applications to microservice architectures and extended scalability. SaaS and cloud services provide great opportunities to save expenses by reducing cost of maintenance in general. But when it comes to building SaaS application itself, a lot of architecture options are available and it is critical for project success to choose the right one.
In this article I will review most common architecture solutions on the example of SaaS API.
Initial project description
Let's assume we need to build an API with user registrations and corporate accounts which can be owned by single user and have other users as members.
Easiest way to create such application is to build a single-database application with properly structured key relations.
This is the best way if the application does not tend to significantly grow in a short period or it will not require scaling to multiple servers or multiple regions.
- Easy maintenance of project within single codebase.
- Consistend database structure.
- Quick deployment.
- Simple authentication management.
- Global project disfunction in case of errors.
- Database maintenance and backup is harder with time.
- Any client-oriented improvement requires updating the whole project.
- Access management must be properly defined within application.
First thing that can be done to improve the case is to split architecture to multiple per-client databases.
This allows to reduce need of access checks within code and ease database maintenance as far as any client-specific failure will not affect the whole service.
- Easier access management provided natively by database system.
- Extended options for database maintenance and backup.
- Improved scalability — databases can be placed on different servers.
- Requires more complex authorization system.
- Database consistency may be violated.
- Any client-oriented improvement still requires updating the whole project.
- Application is still not flexible for load balancing and further scalability
Further development of project may require usage of several servers, client-oriented improvements or any kind of module-based system. Configuration of such environment with a single application instance is quite hard. What can be done here is to provide per-client application system.
- Improved scalability — project is not bound to a single server anymore.
- Load balancing may be provided by increasing amount of servers.
- Any client application can be configured separately with needed modules and packages.
- Requires additional management systems for client application deployment.
- Requires separate authorization server and internal integration of it to the apps.
- Applications are not bound to a single IP/host anymore which may harden its usage.
Further growth of project usually requires using multiple servers for application groups. Mostly this is a requirement for regional expanding or performance optimizations.
All Rights Reserved