Hey everyone,
I've been keeping an eye on my server logs recently and noticed something I hate to see: the gunicorn worker for my Market-Viewr app was periodically dying and being restarted. The application was unstable under load, and it was time to investigate why.
After digging into the logs and doing some performance profiling, the culprit became clear. The application was making frequent, expensive API calls to fetch token richlists from Hive-Engine, especially when a user requested a CSV export. I realized the CSV export was making a separate, fresh pull of the entire richlist, even if the web page had just loaded it. This was inefficient and, for very large richlists, was causing the worker to time out or run out of resources.
To fix this and make the whole application more stable and performant, I've implemented two key backend improvements: caching and retry logic.
The biggest improvement was adding a caching layer. In simple terms, caching stores the result of an expensive operation (like an API call) for a set period. If another request for the same data comes in during that period, the app serves the stored result instead of hitting the API again. This is massively more efficient.
I used the flask-caching
library and set it up with a clever fallback system:
This ensures the app still benefits from caching even if the Redis service isn't running. I've applied different cache timeouts to different pages – for example, the homepage with the list of all tokens is cached for longer, while a specific token's market page has a shorter cache time to keep the data fresher.
The second issue is that sometimes API nodes can have a temporary blip or a network connection can fail. To make the app more resilient to these transient errors, I've configured the requests
library to automatically retry failed requests.
If a connection to the Hive-Engine API fails, the app will now automatically try again a few times with a short delay between attempts. This means a temporary network hiccup is much less likely to result in an error page for the user.
These backend changes should result in a noticeably better experience for you:
While I was in there, I also made a small quality-of-life tweak to sort the richlist by the total holdings (staked + balance) by default, which gives a more accurate picture of a user's position.
These kinds of infrastructure improvements aren't as flashy as a new feature, but they are crucial for a good user experience. I hope you find the updated Market-Viewr to be a smoother and more reliable tool!
As always,
Michael Garcia a.k.a. TheCrazyGM
I just tried Market-Viewr out again, and it's looking and working great! Congratulations on the fixes and refinements! 😁 🙏 💚 ✨ 🤙
I really like Market-Viewr!
I utilize it mainly to view token peice history over a longer peiod in time which isn't available on hive-engine / tribaldex.
Great app!
Is your site available to the public? Can I get the URL?
Absolutely, the main site is https://TheCrazyGM.com
The one I'm talking about today is: https://market.thecrazygm.com
Thanks.
@herman-german Thanks for pointing this out, should have fixed your issue as well.
Looking great now. Thanks for adding these fix 💪
Little by little we shall take over the
worldblockexplorer!!PAKX
!PIMP
!PIZZA
View or trade
PAKX
tokens.Use !PAKX command if you hold enough balance to call for a @pakx vote on worthy posts! More details available on PAKX Blog.
$PIZZA slices delivered:
@ecoinstant(2/20) tipped @thecrazygm
Come get MOONed!
Congratulations @thecrazygm! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP