Background:
In reference to
MA-2678
-
Getting issue details...
STATUS
; we have changed forums implementation with following details (for reference; see PR#192):
- Changed post/response/comment behaviour to update post's 'last_activity_at' only at time of creation of post and creation of response/comment on a post. Previously post's 'last_activity_at' was being updated for both creation and update.
- To calculate 'read' status of a post, used 'last_acitvity_at' instead of 'updated_at'.
- To calculate 'unread comment count' for a post, used 'created_at' instead of 'updated_at'.
'unread comment count' was being calculate as:
unread_comment_count = Comment.collection.find(:comment_thread_id => t._id, :author_id => {"$ne" => user.id}, :updated_at => {"$gte" => read_dates[thread_key]}).count
and had a compound index against it
index({_type: 1, comment_thread_id: 1, author_id: 1, updated_at: 1})
With new implementation:
unread_comment_count = Comment.collection.find(:comment_thread_id => t._id, :author_id => {"$ne" => user.id}, :created_at => {"$gte" => read_dates[thread_key]}).count
So, we removed index
index({_type: 1, comment_thread_id: 1, author_id: 1, updated_at: 1})
and added a new one
index({comment_thread_id: 1, author_id: 1, created_at: 1})
The results of load tests below show difference between the old and new implementation.
The load tests were run on 4x c4.2xlarge instances.
There appears to be anomaly in the results below (highlighted 99%) where the new implementation is faster than the old. Where as, for other results the percentile of new implementation increases significantly with the increase in load. For example, the first pair of results where no. of clients = 48, the difference is in tens or hundrend and for the last pair of results where no. of clients = 610, the difference is in thousands.
Logically; there should only be increase in response time for GET endpoints, but we see in results that all other endpoints show differences too.
New Relic:
Here is the new relic permaLink_without_profile and where the average rpm for former is 1.55k and for later is 1.48k and 84.5% of requests are made for AccountViewSet.list (i.e. user accounts API for multiple usernames) for later.
| |
---|
No. of clients = 48 req/s = 9.4 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 250 | 310 | 1200 | DELETE_thread | 160 | 190 | 200 | GET_comment_list | 150 | 190 | 310 | GET_thread | 140 | 180 | 220 | GET_thread_list | 160 | 370 | 520 | PATCH_comment | 230 | 360 | 1200 | PATCH_thread | 190 | 240 | 370 | POST_comment_comment | 290 | 360 | 430 | POST_comment_response | 250 | 310 | 450 | POST_thread | 160 | 190 | 200 | auto_auth | 200 | 250 | 250 |
| No. of clients = 48 req/s = 9.6 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 260 | 310 | 340 | DELETE_thread | 160 | 200 | 220 | GET_comment_list | 160 | 200 | 290 | GET_thread | 150 | 190 | 260 | GET_thread_list | 170 | 370 | 520 | PATCH_comment | 250 | 410 | 410 | PATCH_thread | 190 | 250 | 1200 | POST_comment_comment | 300 | 390 | 420 | POST_comment_response | 260 | 320 | 410 | POST_thread | 160 | 210 | 310 | auto_auth | 190 | 190 | 190 |
|
No. of clients = 96 req/s = 18.5 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 270 | 340 | 390 | DELETE_thread | 170 | 230 | 330 | GET_comment_list | 170 | 210 | 330 | GET_thread | 160 | 200 | 250 | GET_thread_list | 190 | 440 | 610 | PATCH_comment | 240 | 330 | 360 | PATCH_thread | 200 | 260 | 350 | POST_comment_comment | 310 | 380 | 470 | POST_comment_response | 260 | 330 | 440 | POST_thread | 170 | 210 | 340 | auto_auth | 180 | 220 | 220 |
| No. of clients = 96 req/s = 18.7 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 280 | 370 | 440 | DELETE_thread | 180 | 220 | 270 | GET_comment_list | 170 | 230 | 350 | GET_thread | 160 | 220 | 300 | GET_thread_list | 210 | 500 | 640 | PATCH_comment | 250 | 360 | 1400 | PATCH_thread | 200 | 280 | 380 | POST_comment_comment | 320 | 400 | 510 | POST_comment_response | 270 | 350 | 430 | POST_thread | 170 | 220 | 260 | auto_auth | 190 | 260 | 260 |
|
No. of clients = 162 req/s = 31 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 320 | 400 | 490 | DELETE_thread | 190 | 240 | 280 | GET_comment_list | 190 | 250 | 370 | GET_thread | 190 | 250 | 340 | GET_thread_list | 220 | 520 | 660 | PATCH_comment | 270 | 360 | 390 | PATCH_thread | 230 | 310 | 370 | POST_comment_comment | 350 | 450 | 540 | POST_comment_response | 300 | 400 | 490 | POST_thread | 190 | 240 | 340 | auto_auth | 200 | 200 | 200 |
| No. of clients = 162 req/s = 31.5 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 350 | 500 | 660 | DELETE_thread | 210 | 300 | 390 | GET_comment_list | 210 | 350 | 460 | GET_thread | 210 | 320 | 430 | GET_thread_list | 250 | 620 | 800 | PATCH_comment | 290 | 440 | 570 | PATCH_thread | 260 | 430 | 580 | POST_comment_comment | 380 | 560 | 710 | POST_comment_response | 330 | 480 | 610 | POST_thread | 210 | 310 | 430 | auto_auth | 210 | 230 | 230 |
|
No. of clients = 240 req/s = 44.6 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 400 | 600 | 700 | DELETE_thread | 240 | 320 | 530 | GET_comment_list | 240 | 350 | 480 | GET_thread | 240 | 360 | 470 | GET_thread_list | 270 | 630 | 800 | PATCH_comment | 330 | 510 | 600 | PATCH_thread | 290 | 420 | 530 | POST_comment_comment | 420 | 640 | 820 | POST_comment_response | 360 | 560 | 730 | POST_thread | 240 | 310 | 440 | auto_auth | 210 | 210 | 210 |
| No. of clients = 240 req/s = 44.7 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 540 | 1000 | 1800 | DELETE_thread | 340 | 680 | 2000 | GET_comment_list | 340 | 750 | 1500 | GET_thread | 340 | 710 | 1500 | GET_thread_list | 410 | 1000 | 1700 | PATCH_comment | 420 | 800 | 1300 | PATCH_thread | 400 | 750 | 1300 | POST_comment_comment | 580 | 1100 | 2500 | POST_comment_response | 500 | 940 | 1600 | POST_thread | 340 | 710 | 1000 | auto_auth | 490 | 610 | 610 |
|
No. of clients = 336 req/s = 53 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 2500 | 5500 | 6500 | DELETE_thread | 980 | 2300 | 2900 | GET_comment_list | 800 | 2100 | 2700 | GET_thread | 920 | 2700 | 3300 | GET_thread_list | 850 | 2400 | 3300 | PATCH_comment | 1500 | 3900 | 5000 | PATCH_thread | 1200 | 3400 | 4100 | POST_comment_comment | 2300 | 5400 | 7000 | POST_comment_response | 1700 | 4400 | 5900 | POST_thread | 740 | 2000 | 2700 | auto_auth | 330 | 1300 | 1300 |
| No. of clients = 336 req/s = 48.9 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 2300 | 3400 | 4400 | DELETE_thread | 1700 | 2600 | 3200 | GET_comment_list | 1900 | 2900 | 3900 | GET_thread | 1800 | 2800 | 3700 | GET_thread_list | 2300 | 5200 | 6800 | PATCH_comment | 2200 | 3200 | 4200 | PATCH_thread | 1900 | 3200 | 5500 | POST_comment_comment | 2400 | 3500 | 4300 | POST_comment_response | 2200 | 3200 | 3900 | POST_thread | 1800 | 2800 | 3600 | auto_auth | 1800 | 2100 | 2100 |
|
No. of clients = 460 req/s = 44.5 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 5600 | 9800 | 12000 | DELETE_thread | 3700 | 6200 | 7900 | GET_comment_list | 3700 | 6100 | 8100 | GET_thread | 5200 | 9800 | 13000 | GET_thread_list | 3700 | 6800 | 8600 | PATCH_comment | 4800 | 7900 | 9500 | PATCH_thread | 4600 | 7300 | 9900 | POST_comment_comment | 5500 | 9300 | 11000 | POST_comment_response | 5000 | 8300 | 10000 | POST_thread | 3500 | 6000 | 9200 | auto_auth | 2000 | 2600 | 2600 |
| No. of clients = 460 req/s = 32.4 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 7600 | 38000 | 43000 | DELETE_thread | 6700 | 26000 | 41000 | GET_comment_list | 7200 | 38000 | 42000 | GET_thread | 10000 | 42000 | 47000 | GET_thread_list | 7600 | 40000 | 43000 | PATCH_comment | 7300 | 28000 | 43000 | PATCH_thread | 7300 | 27000 | 43000 | POST_comment_comment | 7800 | 41000 | 43000 | POST_comment_response | 7800 | 38000 | 42000 | POST_thread | 6900 | 28000 | 42000 | auto_auth | 4300 | 4800 | 5400 |
|
No. of clients = 510 req/s = 32.4 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 7700 | 15000 | 27000 | DELETE_thread | 5400 | 12000 | 15000 | GET_comment_list | 6300 | 14000 | 31000 | GET_thread | 8600 | 19000 | 36000 | GET_thread_list | 6400 | 14000 | 32000 | PATCH_comment | 7000 | 14000 | 25000 | PATCH_thread | 6900 | 16000 | 35000 | POST_comment_comment | 7400 | 15000 | 36000 | POST_comment_response | 7000 | 14000 | 26000 | POST_thread | 6000 | 11000 | 32000 | auto_auth | 2900 | 4000 | 4400 |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | OST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | OST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|
No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
| No. of clients = req/s = Methods | median response time | 95% | 99% |
---|
DELETE_comment | | | | DELETE_thread | | | | GET_comment_list | | | | GET_thread | | | | GET_thread_list | | | | PATCH_comment | | | | PATCH_thread | | | | POST_comment_comment | | | | POST_comment_response | | | | POST_thread | | | | auto_auth | | | |
|