Code refactoring
The main achievement of the refactoring was a significant reduction in the rendering time of the “Banquet Halls” section on the server. This was achieved by transferring interaction with the BookBanket service to a background process running on a schedule. Previously, data was received in real time, which greatly slowed down the process. Restaurant parameters required for sorting and filtering are now saved to the site database, and SQL queries have been redesigned and optimised.
Before refactoring, all restaurants and banquet halls were queried, not just those needed by the current page. Under the previous implementation, adding new restaurants would inevitably increase already unacceptable page load times.
Several tables contained obsolete records that were no longer used. For such tables, scheduled cleaning and packing scripts have been added. For example, the time for the simplest query to the vieweds
table was 13 seconds, and the number of records was about 10 million. Records older than 120 days were deleted, and packing the table with the VACUUM
command reduced the size from 9 gigabytes to 37 megabytes.
Before refactoring, the server cache was used irrationally. It was not used to reduce the number of API requests or database calls but as an intermediate means of storing and transferring data between multiple methods. The values from the cache were not reused during the server rendering process but were constantly updated, which did not provide any performance gain. Some fields stored in the cache required sorting and searching. Instead of using fast DBMS tools, the task was performed in an application-level language, resulting in more complex code, an increase (not a decrease!) in the number of database queries, and a loss of performance. Excess code that turned out to be meaningless after refactoring was removed.
A restaurant was hidden if, for example, a network error occurred during an API request or if BookBanket was temporarily unavailable. Since the errors were random, requests for the same page would display different lists of establishments.
In addition to refactoring, multiple changes were made to the layout and functionality of several sections of the site. Defects in ranking banquet halls by price and cost calculation methods were corrected, improving the user experience. Adding SMS authorization to the site also made the user experience more convenient. Finally, bugs with the page counter and paginator were fixed.
Instead of a conclusion