Question
We encountered an issue when the number of online users exceeded 10. In this case, the system starts to lag (the loading wheel spins for more than 1 minute). How can this problem be resolved?
Answer
There are several directions for optimizing projects on totum.
Appropriate server power. The more complex the solution and the more calculations performed with each action, as well as the more users working simultaneously, the more CPU cores and RAM should be available. For the PRO version, the minimum configuration for a system with 10 users is 4 cores and 4GB of RAM.
When you transition to operating the developed solution in the enterprise, we recommend configuring PHP and PostgreSQL on your server. Optimization instructions can be found on the Totum documentation website.
Optimization of the solution architecture. There are several approaches that can significantly slow down the system:
The approach to calculations "take all rows" and "divide by all rows." With such an organization of calculations, the system may function normally during the development stage, but when it starts filling with data, performance will drop sharply.
Tracking simultaneous actions in tables where active writing with long calculations is performed by multiple users. Totum by default tracks simultaneous user actions, but in some cases, it makes sense to disable this, for example, for the Cycles table, as many users actively working with their own cycle will interfere with each other through the common Cycles table.
Very long action chains, especially with calls to external servers. It is necessary to try to limit the length of action chains and ensure that the external server responds quickly enough. If not, asynchronous sending and receiving of data in the background should be implemented.
For queries from large tables, it is advisable to set indexes on the fields used in the where-parameters of functions.
If you use large calculations in formatting codes that are the same for each row, it is worth caching them when calculating the first row by creating a process variable.
It is undesirable to use Select fields with individual calculations in large tables, especially when a Select with individual calculation is taken through a Label field in the Cycles table. In these cases, it is better to make a regular Select and take the value from within the cycle with Code.
It is worth optimizing codes in large calculation tables, as they are calculated in each table field with each action in this table.
Wherever a large number of actions for changing, inserting, and deleting rows are performed, it is advisable to use bulk functions like setList, insertList, deleteList, and so on, to perform one action instead of many through iteration in listReplace.