With this PR, I made quite a few improvements aimed specifically at performance. This was in response to some of the hacky fixes we had to do to keep the system running smoothly, during the last event. Originally, I only planned to do performance of the WebSocket endpoints, but the scope crept.
The two biggest improvements I found, were the rework to the WebSocket handlers, and the updates to the score calculation query.
WebSocket: Using a pub/sub strategy worked wonders. Testing done with the artillery tool showed my poor old system (i5-2520M CPU @ 2.50GHz, 4GB Mem) revitalized, going from a steadily increasing load above 2.50, to a sustainable 0.40, over a minute long evaluation.
Score Calculation: Before calculating the total points per team, adding a simple index on the "points" field, and then pruning all the records where the points were zero, saw speed ups from 2 seconds to under 20ms. Just a little thought, for big gains, on one of the most active DB paths in the app. Tested using vegeta.
Pretty much every database query was looked at, and changed where I felt appropriate. Most of the time, this was either to add concrete types, which make the app easier to trace, or to improve DB index usage, which is known to drastically improves performance.
There are also a handful of small fixes, like the 404 on the favicon, and improved log statements.
With this PR, I made quite a few improvements aimed specifically at performance. This was in response to some of the hacky fixes we had to do to keep the system running smoothly, during the last event. Originally, I only planned to do performance of the WebSocket endpoints, but the scope crept.
The two biggest improvements I found, were the rework to the WebSocket handlers, and the updates to the score calculation query.
Pretty much every database query was looked at, and changed where I felt appropriate. Most of the time, this was either to add concrete types, which make the app easier to trace, or to improve DB index usage, which is known to drastically improves performance.
There are also a handful of small fixes, like the 404 on the favicon, and improved log statements.
Commit shortlog
Closes #24