Benchmarking hivemind API calls after switching to postgREST server

@blocktrades · 2024-11-14 22:57 · HiveDevs

blocktrades update.png

I'll make a full report on our recent work soon, probably next week, but in the meantime I wanted to share the performance improvement we're seeing after switching hivemind from the python based server to postgREST.

We've had several devs working on this task for a few months now; it was a big job as there was a lot of python code in the "server" portion of hivemind that needed to be replaced by SQL code in order for us to switch to using postgREST as hivemind's web server.

But the performance improvements seem well worth it: of the API calls we've benchmarked, we're generally seeing speedups between 3-4x faster on average. We had a few regressions where we still need to tweak the SQL code to get optimal performance (e.g. get_discussions_by_created, get_following), but for our very first benchmark of the old and new code, I'm quite pleased.

Here's the old/new benchmark data below. The median column shows the median time for the API call to complete and is probably one of the most useful figures of merit for comparing the two servers.

Generally speaking, I think the most noticeable speedup will be for "quick" API calls, due to the reduced fixed-overhead latency of postgREST. But we can see cases where just the replacement of python code with equivalently-functioning SQL has resulted in good speedups as well.

Old Python-based Server:

Endpoint Max [ms] Min [ms] Average [ms] Median [ms]
condenser_api.get_discussions_by_blog 7311 115 2399 2399
bridge.get_account_posts 6237 55 1011 897
bridge.get_discussion 15793 3 1610 206
bridge.get_ranked_posts 2511 226 893 862
condenser_api.get_discussions_by_comments 883 5 384 430
condenser_api.get_followers 387 21 85 63
condenser_api.get_discussions_by_created 2590 49 562 255
bridge.get_profile 1102 349 574 531
condenser_api.get_discussions_by_feed 2206 1411 1883 1915
condenser_api.get_blog 4482 1070 3299 3564
condenser_api.get_following 362 167 221 201

New PostgREST Server:

Endpoint Max [ms] Min [ms] Average [ms] Median [ms]
condenser_api.get_discussions_by_blog 2858 66 638 669
bridge.get_account_posts 5402 9 344 252
bridge.get_discussion 36736 1 2705 50
bridge.get_ranked_posts 5041 106 431 233
condenser_api.get_discussions_by_comments 277 1 102 111
condenser_api.get_followers 121 11 48 19
condenser_api.get_discussions_by_created 28137 30 2352 1266
bridge.get_profile 1079 308 559 455
condenser_api.get_discussions_by_feed 722 479 599 588
condenser_api.get_blog 1376 323 885 914
condenser_api.get_following 1352 246 1053 1211

Next up, production testing

Note these are results are from a synthetic benchmark we've created, not from real world traffic testing.

After we fix the API calls with performance regressions, we'll setup a server with the optimized code and direct a copy of production traffic to it as a final test.

#hive-139531 #hive #blockchain #software #blocktrades
Payout: 0.000 HBD
Votes: 1000
More interactions (upvote, reblog, reply) coming soon.