create account

Hive API node performance measurement by blocktrades

View this thread on: hive.blogpeakd.comecency.com
· @blocktrades · (edited)
$31.40
Hive API node performance measurement
This post describes the [Jussi Traffic Analyzer](https://gitlab.syncad.com/hive/jussi-traffic-analyzer)  software that we created to measure the performance of our production Hivemind node and some of the results we’ve recently obtained from it.

The intended audience is mostly Hive apps developers and API node operators, but if you're like me and sometimes you like to read something very techy even though it's hard to understand (I used to do this with Scientific America articles when I was kid), feel free to enjoy as well.

It’s important to note that this tool analyzes Jussi log files, so it’s not really useful for measuring third party API nodes (unless the node operator is willing to provide you with their logs, which is probably doubtful).

The tool generates two reports over any specified period of the log files:

* `analysis.csv` which contains statistics on the different API calls
* `slow_calls.txt` which contains actual calls that exceeded a specified time to complete (for example > 2 seconds)

# Overview of API call statistics file (analysis.csv)

The data in slow_calls.txt is self-explantory, so I’ll spend most of the time in this post discussing the format of the analysis.csv file. 

Each row in the analysis file represents a specific type of API call (the first columns, there's actually 3 columns, although I only show one in the screenshot to keep it readable, identify what this API call is). 

One thing to keep in mind, however, is that a single type of API call can result in quite different SQL queries inside hivemind, depending on the parameters passed to the call, so there’s still a lot of data being “averaged” together in this report. For example, the time required to make a call to get_ranked_posts can vary a lot depending on whether you’re asking for ranked by trending, hot, etc. Nonetheless, I think this data can still be quite useful for obtaining some intuitive feeling for the times required by various calls. 

Here’s a screenshot of a sample analysis file (I’ll make the raw data file available in the mattermost Hive dev channel later today). This data was taken today from our production node over a two hour period, running with our latest hivemind optimizations. Note that this screenshot doesn’t show all the columns in the raw data file, I’ve selected ones of particular interest to discuss in this post.

* Hits is the number of jussi cache hits. Cache hits are generally low, because parameter values vary a lot and also because many of the responses to API calls change quickly (votes, in particular, can change the results for many API calls). So this data is mostly useful for optimization work when you're able to change the API itself.
* *AvgTime* is the average time of all the API calls of this type.
* *SlowestTime* is the slowest time recorded during the analysis period for this API call.
* *Total#Calls* is the total number of calls to this API node of this type of API call during the analysis period.
* *Slow(1s+)* is the total number of calls to this API node of this type of API call during the analysis period that take 1 second or more to complete.
* *AvgSlow* is the average time of such slow calls (so it will always be greater than 1s).
* *Slow%* is the percentage of the total calls of this type that take more than 1 second to complete.
* *TotalTime* is the total time consumed by adding up all the calls made for this API call. For example, if there were 100 calls and each one takes .1 s, then this value would be 10s.


![image.png](https://images.hive.blog/DQmQqDTqhD8tasfS5KaXX4qQU15CWSt5W4nBoNPgB3JUx6D/image.png)

# Some notes about using these metrics

I use *TotalTime* to measure the overall loading impact of a particular type of API call on the server, although there are some exceptions to this rule, such as broadcast_transaction_synchronous, which has to wait for a block to complete so that the transaction can be included in a block, but doesn’t consume CPU while waiting. This is the single most important metric for determining how well a node can scale to handle more traffic.

I use *SlowestTime*, *Slow*, *Slow%* to investigate potential quality of service problems that might affect user experience (users don’t generally like to wait long to see results).

*AverageFast* is useful for knowing what you can normally expect from an API call when you exclude “outlier” calls that access “unusual” data (for example it would exclude timing data from a post with many thousands of comments). So this is a very useful metric for apps developers.

# Notes on the sample data

After generating the two reports with the Jussi Traffic Analyzer, I import the analysis file into LibreOffice Calc or a similar spreadsheet program to analyze the data, then use AutoFilter so that I can sort on different columns. 

In the screenshot shown, I’ve sorted by *AvgFast* time, and we can see that the API call that takes the longest time on average in all cases and in the “fast” case is `get_block_range`. This API call is served by hived, not hivemind, and you can see that it takes considerably more time than the average API call (the average “fast” time is .753s and the average time overall is 2.4s!). 

One of the objectives of our work with the hived plugin that will feed data directly to a Postgres database is to speedup this time by having hivemind, rather than hived, serve this API call in the future (and not coincidentally, reduce the loading caused by hivemind sync time, because currently hivemind makes this call to obtain sync data from hived).

# Using pghero to supplement analysis of node performance

In addition to the Jussi Traffic Analyzer, I also use pghero, an open-source web-based profiling tool for Postgres databases,  to directly analyze the impact of various queries within hivemind’s database.

Pghero is particularly useful in isolating problematic SQL queries when a given hivemind API call is implemented using multiple SQL queries (either serially or by branching between possible query choices, which is quite common).

However, pghero can only report on times spent in database processing, so the Jussi Traffic Analysis  tool is still very important for measuring overall performance, including the time spent by the python-based `hivemind server` process that communicates with hivemind’s database. And it can also measure the performance of hived-based API calls, which pghero cannot, since the processing of hived API calls  doesn’t involve Postgres queries.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 500 others
👎  , , , , , , , , , , , , , , , , ,
properties (23)
authorblocktrades
permlinkhive-api-node-performance-measurement
categoryhive-139531
json_metadata{"tags":["hive","blockchain","software","blocktrades","hivemind"],"image":["https://images.hive.blog/DQmQqDTqhD8tasfS5KaXX4qQU15CWSt5W4nBoNPgB3JUx6D/image.png"],"links":["https://gitlab.syncad.com/hive/jussi-traffic-analyzer"],"app":"hiveblog/0.1","format":"markdown"}
created2021-01-06 01:42:33
last_update2021-01-06 01:49:09
depth0
children17
last_payout2021-01-13 01:42:33
cashout_time1969-12-31 23:59:59
total_payout_value18.152 HBD
curator_payout_value13.252 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6,496
author_reputation1,291,658,814,228,425
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,238,500
net_rshares163,076,864,152,146
author_curate_reward""
vote details (582)
@btcmillennial ·
https://media1.giphy.com/media/vnFB72LzHtO4o/giphy.gif?cid=6c09b952aea3941e0e0fc5777d5e01c9e7a0542f4b9ff308&rid=giphy.gif
properties (22)
authorbtcmillennial
permlinkqmhsmj
categoryhive-139531
json_metadata{"image":["https://media1.giphy.com/media/vnFB72LzHtO4o/giphy.gif?cid=6c09b952aea3941e0e0fc5777d5e01c9e7a0542f4b9ff308&rid=giphy.gif"],"app":"hiveblog/0.1"}
created2021-01-06 03:06:21
last_update2021-01-06 03:06:21
depth1
children0
last_payout2021-01-13 03:06:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length121
author_reputation12,319,059,273,546
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,239,875
net_rshares0
@davidmuhammad ·
Thanks
properties (22)
authordavidmuhammad
permlinkre-blocktrades-202116t20543295z
categoryhive-139531
json_metadata{"tags":["hive","blockchain","software","blocktrades","hivemind"],"app":"ecency/3.0.11-mobile","format":"markdown+html"}
created2021-01-06 13:05:42
last_update2021-01-06 13:05:42
depth1
children0
last_payout2021-01-13 13:05:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6
author_reputation6,813,184,461,391
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,245,542
net_rshares0
@hivebuzz ·
Congratulations @blocktrades! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@blocktrades/upvoted.png?202101060210"></td><td>You received more than 95000 upvotes. Your next target is to reach 100000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@blocktrades) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the last post from @hivebuzz:**
<table><tr><td><a href="/hivebuzz/@hivebuzz/pud-202101-feedback"><img src="https://images.hive.blog/64x128/https://i.imgur.com/xQGM37X.png"></a></td><td><a href="/hivebuzz/@hivebuzz/pud-202101-feedback">Feedback from the January 1st Hive Power Up Day</a></td></tr><tr><td><a href="/hivebuzz/@hivebuzz/update-202101"><img src="https://images.hive.blog/64x128/https://i.imgur.com/GZV4AF7.png"></a></td><td><a href="/hivebuzz/@hivebuzz/update-202101">Happy New Year - Project Activity Update</a></td></tr></table>
properties (22)
authorhivebuzz
permlinkhivebuzz-notify-blocktrades-20210106t023117000z
categoryhive-139531
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2021-01-06 02:31:15
last_update2021-01-06 02:31:15
depth1
children0
last_payout2021-01-13 02:31:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,196
author_reputation370,798,271,494,817
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,239,522
net_rshares0
@lallo ·
Hi @blocktrades i have a question:
I think I read some time ago that the get_follower/ing calls will be served by hivemind and no more by the follow_api. Is it correct?
The follow api no longer exist? And all its methods are now served by the hivemind api? So also get_follow_count?
Thanks
properties (22)
authorlallo
permlinkre-blocktrades-qmhtid
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.12.3"}
created2021-01-06 03:25:30
last_update2021-01-06 03:25:30
depth1
children6
last_payout2021-01-13 03:25:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length289
author_reputation17,911,923,039,729
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,240,037
net_rshares0
@blocktrades ·
get_followers/following are definitely served by hivemind, and have been for quite a while I think (as long as Hive existed, I believe, but not 100% sure without checking). But we've moved some other API functionality from hivemind to hived (reputation, notifications, and voting data) as part of Eclipse work to reduce memory usage by hived and improve API speed.
properties (22)
authorblocktrades
permlinkqmi0p2
categoryhive-139531
json_metadata{"app":"hiveblog/0.1"}
created2021-01-06 06:00:39
last_update2021-01-06 06:00:39
depth2
children5
last_payout2021-01-13 06:00:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length364
author_reputation1,291,658,814,228,425
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,241,695
net_rshares0
@lallo ·
Yeah I know...great work and thank you for your answer!!

From my little experience, I noticed a huge improvement on the api.hive.blog node. Before that node was one of the worst, now it's the best :)
properties (22)
authorlallo
permlinkre-blocktrades-qmimpq
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.12.3"}
created2021-01-06 13:56:18
last_update2021-01-06 13:56:18
depth3
children4
last_payout2021-01-13 13:56:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length200
author_reputation17,911,923,039,729
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,246,160
net_rshares0
@marki99 ·
$0.20
I understood everything as a non-dev, great job explaining. Where is the previous performance before all the upgrades? Need something to compare to. 
👍  ,
properties (23)
authormarki99
permlinkre-blocktrades-qmi28h
categoryhive-139531
json_metadata{"tags":["hive-139531"],"app":"peakd/2020.12.3"}
created2021-01-06 06:33:54
last_update2021-01-06 06:33:54
depth1
children1
last_payout2021-01-13 06:33:54
cashout_time1969-12-31 23:59:59
total_payout_value0.098 HBD
curator_payout_value0.099 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length149
author_reputation11,400,723,818,181
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,241,887
net_rshares1,505,476,542,838
author_curate_reward""
vote details (2)
@blocktrades · (edited)
I have some old files with previous data at various times in the past, of course, but the reporting format became more sophisticated with time as I learned more about the nature of the data, so it will take a little massaging to make a direct apples-to-apples comparison. Eventually I'm planning a proposal for the work we did, and I'll likely include an overview of that type of data with the proposal, so that people can more easily evaluate the quality of the work.
👍  
properties (23)
authorblocktrades
permlinkqmi2jk
categoryhive-139531
json_metadata{"app":"hiveblog/0.1"}
created2021-01-06 06:40:33
last_update2021-01-06 06:52:21
depth2
children0
last_payout2021-01-13 06:40:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length468
author_reputation1,291,658,814,228,425
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,241,936
net_rshares2,969,108,210
author_curate_reward""
vote details (1)
@minnowspower ·
!wine
properties (22)
authorminnowspower
permlinkqmhsbv
categoryhive-139531
json_metadata{"app":"hiveblog/0.1"}
created2021-01-06 02:59:57
last_update2021-01-06 02:59:57
depth1
children1
last_payout2021-01-13 02:59:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5
author_reputation2,668,591,933,105
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,239,810
net_rshares0
@wine.bot ·
<center>
<sup>Cheers, @minnowspower You Successfully Shared <b>0.100 WINE</b> With @blocktrades.</sup>
<sup>You Earned <b>0.100 WINE</b> As Curation Reward.</sup>
<sup>You Utilized <b>2/3</b> Successful Calls.</sup>

<img src="https://files.peakd.com/file/peakd-hive/hiveupme/U5hr4v6K-Wine2Greeting.png" alt="wine-greeting">

---
<sup>[WINE Current Market Price](https://hive-engine.com/?p=market&t=TESTO) : <b>0.000 HIVE</b></sup>
</center>
properties (22)
authorwine.bot
permlink20210106t030015516z
categoryhive-139531
json_metadata{"tags":["wine","wineyard"],"app":"tan-bot/1.1","format":"markdown"}
created2021-01-06 03:00:15
last_update2021-01-06 03:00:15
depth2
children0
last_payout2021-01-13 03:00:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length442
author_reputation8,838,960,845,284
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,239,817
net_rshares0
@omarrojas ·
Thank you very much for motivating our publications, that keeps us activated to continue growing. Successes in your publications and cures, sincere wishes from Venezuela.
properties (22)
authoromarrojas
permlinkqmy7ap
categoryhive-139531
json_metadata{"app":"hiveblog/0.1"}
created2021-01-14 23:44:51
last_update2021-01-14 23:44:51
depth1
children0
last_payout2021-01-21 23:44:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length170
author_reputation419,622,748,973,010
root_title"Hive API node performance measurement"
beneficiaries
0.
accounthiveonboard
weight100
1.
accounttipu
weight100
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,380,146
net_rshares0
@petrarodriguez ·
muy buen trabajo,lo felicito,espero contar con su voto y apoyo,necesito comprar un celular para trabajar aqui,no tengo,el computador se daño ,he publicada gracias a una amiga pero sin fotos,gracia samigo por ver si me ayuda
properties (22)
authorpetrarodriguez
permlinkqmoruu
categoryhive-139531
json_metadata{"app":"hiveblog/0.1"}
created2021-01-09 21:03:00
last_update2021-01-09 21:03:00
depth1
children0
last_payout2021-01-16 21:03:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length223
author_reputation138,678,876,756,376
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,297,161
net_rshares0
@zekepickleman ·
Though the complexity of this makes my head hurt a little, the transparency of your operations and education of the coders makes my heart feel good.

Thanks again for being a technology enabler and great blockchain citizen!


![beerologistapproved.png](https://images.hive.blog/DQmNgNnMcCKvgcGEA9cRmeFgGza8CydHE1eAYgtGtv2sqgU/beerologistapproved.png)
properties (22)
authorzekepickleman
permlinkqmippy
categoryhive-139531
json_metadata{"image":["https://images.hive.blog/DQmNgNnMcCKvgcGEA9cRmeFgGza8CydHE1eAYgtGtv2sqgU/beerologistapproved.png"],"app":"hiveblog/0.1"}
created2021-01-06 15:01:12
last_update2021-01-06 15:01:12
depth1
children0
last_payout2021-01-13 15:01:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length350
author_reputation783,463,099,025,874
root_title"Hive API node performance measurement"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,247,120
net_rshares0