With the addition of new query param (i.e. requested_fields=profile_image) to discussion API GET endpoints for thread and comment; the discussion APIs got exposed to the possibility of performance degradation because this new param fetches and prepares the profile image related data of all the users that are participating in thread or comment.
We have gathered and compared two sets of load test results. The former results (i.e. with profile_image) are run on the latest changes and the later are run on older implementation (i.e. without profile_image).
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. This is because all PATCH, POST and DELETE endpoints first call GET endpoint to retrieve an 'id' of thread and/or comment and then make further processing on it.
New Relic:
Here is the new relic permaLink_without_profile and permaLink_with_profile 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 |
Background:
In reference to
Jira Legacy |
---|
server | JIRA (openedx.atlassian.net) |
---|
serverId | 13fd1930-5608-3aac-a5dd-21b934d3a4b4 |
---|
key | MA-2678 |
---|
|
; 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})
Results:
The load tests were run on 4x c4.2xlarge instances for lms and 3x m4.large instances for forums.
The results of load tests below show differences between the old and new implementation. The two set of results looks quite similar except when it reaches "No. of clients = 336"; where there is huge difference between old and new percentiles as well as sudden rise in percentile for both old and new index with respect to "No. of clients = 224". For all the next tests (i.e. No. of clients = 460, No. of clients = 510, No. of clients = 578), the difference between old and new percentile is minimised and the new index results have lower percentile for most of the endpoints.
I have captured new relic charts too; permaLink_old_index with average rpm = 1.86k and permaLink_new_index with average rpm = 1.81k
| |
---|
No. of clients = 46048 req/s = 449.54 Methods | median response time | 95% | 99% |
---|
DELETE_comment | 5600 250 | 980031012000 | 1200 | DELETE_thread | 3700 160 | 62001907900 | 200 | GET_comment_list | 3700150 | 61001908100 | 310 | GET_thread | 5200140 | 980018013000 | 220 | GET_thread_list | 3700160 | 68003708600 | 520 | PATCH_comment | 4800230 | 79003609500 | 1200 | PATCH_thread | 4600190 | 73002409900 | 370 | POST_comment_comment | 5500290 | 930036011000 | 430 | POST_comment_response | 5000250 | 830031010000 | 450 | POST_thread | 3500160 | 60001909200 | 200 | auto_auth | 2000200 | 26002502600 | 250 |
| No. of clients = 46048 req/s = 328.49 Methods | median response time | median response time | 95% | 95% | 99% | 99% |
---|
DELETE_comment | 7600 | 38000 | 43000 | 250 | 270 | 300 | 470 | 480 | 520 | DELETE_thread | 6700 | 26000 | 41000 | 170 | 160 | 210 | 300 | 230 | 310 | GET_comment_list | 7200 | 38000 | 42000 | 150 | 160 | 200 | 260 | 320 | 350 | GET_thread | 10000 | 42000 | 47000 | 150 | 150 | 190 | 250 | 280 | 310 | GET_thread_list | 7600 | 40000 | 43000list | 170 | 190 | 360 | 370 | 520 | 530 | PATCH_comment | 7300 | 28000 | 43000 | 220 | 240 | 320 | 400 | 410 | 460 | PATCH_thread | 7300 | 27000 | 43000 | 180 | 190 | 360 | 300 | 330 | 330 | POST_comment_comment | 7800 | 41000 | 43000290 | 310 | 340 | 510 | 490 | 680 | POST_comment_response | 7800 | 38000 | 42000 | POST_thread | 6900 | 28000 | 42000 | 250 | 260 | 300 | 450 | 390 | 520 | POST_thread | 160 | 160 | 200 | 250 | 370 | 340 | auto_auth | 4300 | 4800 | 5400 | 220 | 210 | 230 | 230 | 230 | 230 |
|
No. of clients = | 51096 req/s = | 3218. | 45 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| 7700 | 15000 | 27000 | 5400 | 12000 | 15000 | 6300 | 14000 | 31000 | 8600 | 19000 | 36000 | 6400 | 14000 | 32000 | 7000 | 14000 | 25000 | 6900 | 16000 | 35000 | 7400 | 15000 | 36000 | 7000 | 14000 | 26000 | 6000 | 11000 | 32000 | 2900 | 4000 | 4400
| No. of clients = 96 req/s = 18.6 Methods | median response time | median response time | 95% | 95% | 99% | 99% |
---|
DELETE_comment |
| | | | 270 | 280 | 340 | 360 | 360 | 980 | DELETE_thread |
| | | | 170 | 170 | 220 | 230 | 230 | 290 | GET_comment_list |
| | | | 160 | 160 | 210 | 220 | 340 | 400 | GET_thread |
| | | | 160 | 160 | 200 | 210 | 270 | 340 | GET_thread_list |
| | | | 190 | 190 | 460 | 460 | 600 | 640 | PATCH_comment |
| | | | 220 | 230 | 310 | 310 | 340 | 460 | PATCH_thread |
| | | | 190 | 200 | 260 | 280 | 350 | 1000 | POST_comment_comment |
| | | | 300 | 310 | 370 | 410 | 480 | 680 | POST_comment_response |
| | | | 260 | 260 | 330 | 350 | 420 | 620 | POST_thread |
| | | | 170 | 170 | 210 | 210 | 340 | 330 | auto_auth |
| | |
|
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 | OSTPOST_comment_response | 300 | 400 | 490 | POST_thread | 190 | 240 | 340 | auto_auth | 200 | 200 | 200 |
| No. of clients = 162 req/s = Methods31.6 Methods | median response time | median response time | 95% | 95% | 99% | 99% |
---|
DELETE_comment | | | | 310 | 320 | 410 | 420 | 590 | 530 | DELETE_thread | | | | 190 | 190 | 240 | 230 | 250 | 250 | GET_comment_list | | | | 190 | 190 | 250 | 250 | 380 | 380 | GET_thread | | | | 180 | 180 | 250 | 250 | 360 | 340 | GET_thread_list | | | | 220 | 210 | 530 | 520 | 670 | 660 | PATCH_comment | | | | 260 | 250 | 380 | 360 | 1400 | 430 | PATCH_thread | | | | 220 | 230 | 280 | 310 | 400 | 370 | POST_comment_comment | | | | OST | 340 | 340 | 450 | 470 | 540 | 620 | POST_comment_response | | | | 290 | 290 | 400 | 400 | 510 | 550 | POST_thread | | | | 190 | 190 | 240 | 230 | 370 | 360 | auto_auth | | | | 210 | 200 | 220 | 200 | 220 | 200 |
|
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 = 45.40 Methods | median response time | median response time | 95% | 95% | 99% | 99% |
---|
DELETE_comment | | | | 390 | 410 | 650 | 690 | 1300 | 1100 | DELETE_thread | | | | 240 | 230 | 370 | 280 | 430 | 340 | GET_comment_ | list | | list | 230 | 240 | 350 | 350 | 500 | 480 | GET_thread | | | | 230 | 240 | 370 | 370 | 600 | 520 | GET_thread_list | | | | 270 | 270 | 640 | 630 | 850 | 790 | PATCH_comment | | | 300 | 310 | 490 | 480 | 1200 | 610 | PATCH_thread | | | | 280 | 290 | 460 | 470 | 640 | 630 | POST_comment_comment | | | 410 | 430 | 670 | 660 | 1000 | 970 | POST_comment_response | | | | 360 | 360 | 560 | 600 | 860 | 850 | POST_thread | | | | 230 | 230 | 300 | 310 | 500 | 430 | auto_auth | | | | 190 | 210 | 220 | 220 | 220 | 220 |
|
| No. of clients = 270 req/s = 51.1 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | | | | 10000 | POST_comment_response |
| | | | | | | | | |
| No. of clients = 300 req/s = 48 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | | | | 5500 | POST_comment_response |
| | | | | | | | | |
No. of clients = 336 req/s = 53 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | | | | 7000 | POST_comment_response |
| | | | | | | | |
| No. of clients = 336 req/s = | 54.3 Methods | median response time | median response time | 95% | 95% | 99% | 99% |
---|
DELETE_comment |
| | | | 1500 | 5300 | 9200 | 9600 | 12000 | 11000 | DELETE_thread |
| | | | 470 | 2300 | 4100 | 4600 | 6700 | 5100 | GET_comment_list |
| | | | 510 | 1800 | 5000 | 3700 | 6800 | 4500 | GET_thread |
| | | | 590 | 2100 | 6500 | 4800 | 9900 | 5700 | GET_thread_ |
| list | | list | 580 | 1800 | 4900 | 3900 | 6800 | 4800 | PATCH_comment |
| | | | 810 | 3500 | 7600 | 6400 | 1100 | 9700 | PATCH_thread |
| | | | 790 | 2900 | 5400 | 6300 | 7800 | 7300 | POST_comment_comment |
| | | 1300 | 4800 | 9300 | 9300 | 12000 | 11000 | POST_comment_response |
| | | | 1000 | 3700 | 7700 | 7800 | 10000 | 9600 | POST_thread |
| | | 470 | 1700 | 4600 | 3500 | 6400 | 4000 | auto_auth |
| | |
|
No. of clients = 460 req/s = 44.5 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | | | | 11000 | POST_comment_response |
| | | | | | | | |
| No. of clients = 460 req/s = 49.1 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | | | | 11000 | POST_comment_response |
| | | | | | | | |
|
No. of clients = 510 req/s = 32.4 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | 35000 | POST_comment_comment |
| | | 36000 | POST_comment_response |
| | | | | | | | |
| No. of clients = 510 req/s = 33.9 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | 21000 | POST_comment_comment |
| | | 19000 | POST_comment_response |
| | | | | | | | |
|
No. of clients = 578 req/s = 26.70 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | 29000 | POST_comment_comment |
| | | | POST | | | | | | | | |
| No. of clients = 578 req/s = 40.2 Methods | median response time | 95% | 99% |
---|
DELETE_comment |
| | | | | | | | | | | | | | | | | | | | | 28000 | POST_comment_comment |
| | | | POST | | | | | | | | |
|