# Resource scaling You can launch several container instances of one resource (application or DBMS). This may be necessary to increase the fault tolerance of the project and distribute the load between instances. ```{eval-rst} .. admonition:: Attention :class: attention Not every site, bot or web application can work effectively when launched in multiple instances. ``` ## Situations that require scaling Here are examples of how an application can be redesigned to support multiple instances. These examples are simplified and should only be considered as a starting point for designing scalable applications. **Example 1**. The Telegram bot works in survey mode. If you run it in several copies, then each of them will receive the same events from the telegram. Consequently, the bot will respond to an event as many times as there are instances running it. This is most often an error and an example of an application that does not support horizontal scaling. What can be done? You can switch the bot from polling mode to webhooks mode. In this case, the bot will not ask telegram events, and telegram will send events to the bot. These events will be received by the Amverum load balancer and distributed across the bot instances. This way the bot will react only once to one event. Therefore, the error will be resolved and the application can support horizontal scaling. **Example 2**. The online store stores the user's shopping cart in RAM. If such an online store is launched in two copies, some requests will come to one copy, and some to the second. So, the user can have two different shopping carts, and between page reloads the user will see one or the other. This is a bug and an example of an application that does not support horizontal scaling. What can be done? You can connect a database (best) or at least store the user's cart in files, available to all instances of the application. In this case, no matter which instance of the online store receives the request, it will work with the same basket. Therefore, the error will be resolved and the application can support horizontal scaling. ## Changing the number of replicas Once you've verified that your application supports horizontal scaling, you can increase the number of instances on the project page. After you have specified the required number of copies, click on the "Apply" button: ![scaling](../img/scaling.png) After scaling the application, the required number of instances will be displayed. If the display does not occur, reload the browser page. ![scaled](../img/scaled.png) After clicking the button, additional containers will be launched (or extra ones will be stopped). It takes time for containers to start and stop, so the current number of containers will change within a few minutes. If you set the number of containers to 0, the project will be completely stopped (and no funds will be debited for it).