Waivio

Recommended Posts

Benchmarking hivemind API calls after switching to postgREST server

0 comments

blocktrades118.6 K53 seconds agoHive.Blog3 min read

https://images.hive.blog/DQmSihw8Kz4U7TuCQa98DDdCzqbqPFRumuVWAbareiYZW1Z/blocktrades%20update.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:

EndpointMax [ms]Min [ms]Average [ms]Median [ms]
condenser_api.get_discussions_by_blog731111523992399
bridge.get_account_posts6237551011897
bridge.get_discussion1579331610206
bridge.get_ranked_posts2511226893862
condenser_api.get_discussions_by_comments8835384430
condenser_api.get_followers387218563
condenser_api.get_discussions_by_created259049562255
bridge.get_profile1102349574531
condenser_api.get_discussions_by_feed2206141118831915
condenser_api.get_blog4482107032993564
condenser_api.get_following362167221201

New PostgREST Server:

EndpointMax [ms]Min [ms]Average [ms]Median [ms]
condenser_api.get_discussions_by_blog285866638669
bridge.get_account_posts54029344252
bridge.get_discussion367361270550
bridge.get_ranked_posts5041106431233
condenser_api.get_discussions_by_comments2771102111
condenser_api.get_followers121114819
condenser_api.get_discussions_by_created281373023521266
bridge.get_profile1079308559455
condenser_api.get_discussions_by_feed722479599588
condenser_api.get_blog1376323885914
condenser_api.get_following135224610531211

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.

Hashtags 5
HiveDevs - A community of developers working on Hive related projects. Visit our Discord at https://discord.gg/cvnByhu

Comments

Sort byBest
AI
Waivio AI Assistant
How can I help you today?