The LogClient functionality is used in the Web POS to generate log messages in the client side, which are then synchronized to the backend side so they can be later on analyzed easily.
Currently it is working correctly in general, although there are two improvements which can be done to increase performance and reduce the database space and network bandwith this functionality uses.
Phase 1: Space and bandwith improvement
Currently the log client is sending the same information twice to the backend (as separate properties, and then as part of a big JSON object which contains the same information). This can be easily improved so that the requests take half the network bandwidth.
Apart from this, the backend table itself contains also separate columns for each property, and also a column for the JSON information, which means that it is taking double the required space in the database. This can also be improved.
Phase 2: Performance on the client side
Currently it seems the log client degrades a bit (or significantly, depending on the case) the performance of the client side, due to the fact that every message is immediately saved via a separate transaction in the local database. Over the day, this can add up significantly, and as we have seen in previous analysis, writing in the local database seems to be particularly expensive from the performance point of view.
The main idea here is to reduce these writings to the local database, via several possible optimizations:
- First, there is no need to write any single log message in the local database immediately. We could be adding these messages in a queue in memory, and only write them to the local database if the request to send them to the backend fails.
- Secondly, messages could be accumulated and written to the local database in one single entry, to try to minimize the number of writes. These messages could then be separated before saving them in the backend table.
- Thirdly, it could be analyzed if it made sense to use a different kind of storage in the client side, or if storing it in the client side is necessary.