How to best setup an API backend
I have an app that has an API it calls. The API get’s called multiple times a second from the app’s users.
One aspect of the API calls is the recording if usage statistics.
Currently I have all of this managed on a dedicated server at a local hosting company. I have however noticed that the CPU-loads tend to get pretty high on peak usage times.
I am wanting to upgrade to a more professional solution.
From what I have researched it would be wise to create multiple droplets.
- a droplet for the web server that serves the API (PHP-scripts) and
- a droplet that hosts the mariaDB/mySQL database
In the future I can clone the web server droplet to handle its load demands. I assume I can then use the Digital Ocean’s load balancer to mediate between the droplets.
But what about the mySQL database droplet? I can’t clone the database to balance it’s load - I would have duplicate data. How do I best go about dealing with it’s load? Same question is regarding the size. At the current rate the database grows approx. 5 GB a month. The more users come the faster it will grow. Is my only solution to expand the droplet’s disk space, or can I then split the database across multiple droplets? The usage statistics database itself constists of mainly 3 very large tables. I am sure I could split each table on a separate server, but that should make JOIN statements difficult.
I realize that some of these questions are very future-oriented, but if I am already setting everything up new, I want to setup up every thing so that it is less work when things need to expand. I am trying to prevent time-costly caveats unknowningly.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×