https://wejick.wordpress.com/2022/01/29/can-i-have-a-smaller-prometheus/ In My Honest Opinion Just take it easy in your mind Menu Skip to content * Home * Sejarahku * ShoutBOX Can I have a smaller Prometheus Posted on January 29, 2022 by wejick Prometheus | Power Devops For the past few weeks, I've been thinking about having a time series DB and visualization tool that is easy to use and light on resources, so it can be used locally for development. Tried several times to find it with keywords such as "Grafana alternative", "Prometheus alternative", nothing to be seen as an alternative close to my liking. At one stage I almost write my own tools, which will be too big an undertaking for me. So why not just use Prometheus? Well not until you see the binary size of it, a whopping 103.93 MB. Not surprising for a statically linked executable, but still, it's big. Yesterday morning I told myself, why not make it smaller? How hard it can be right? Well at least smaller on the binary size, as I'm not yet informed enough to do a runtime utilization measurement on it. The first thing I did after getting access to the code is to just remove whatever code I deemed not necessary. Like one time I completely remove tracing and alerting functionality, but that's only reducing a maximum of 2MB. This comes with a lot bunch of modified files and breaking test cases. Definitely not the right way, we need to do it smarter. The weight After browsing for a binary size analysis tool I found goweight. It helps to determine what's contributing to the binary size : [gambar-edi] No surprise to see that the main contributors are cloud provider SDKs, but it's still disappointing. At this stage, it is just a matter of finding where those are being used. A simple text search revealed that all the SDKs are mainly for Service Discovery (SD), for local development file-SD are more than enough. [gambar-5] After tinkering here and there, the very minimum change to exclude all unused SD is to comment them out in the in discovery/install/ install.go . With this change, all tests are passed except one test related to zookeeper initialization. The binary got reduced to just 35.69 MB, just 34% from the original one. [gambar-6] Wrap Up After stripping the debugging info using -ldflags="-s -w", the size got reduced quite bit more. At the end we reduced the size to 28.30% of the original file to just 29.42 MB. [gambar-8] It's crazy when you think that more than 50% (I'm being generous) of the size is something most people will not use, maybe this is the price of modern computation where 50MB means nothing. To be fair Prometheus developers are kinda aware of this and putting the discussion in the readme of service discovery, however, the binary size is not discussed there. There are several potential ways to reduce the file size, like by using upx to package the file. However it's not readily available on brew, so I just skipped it. Another way is just to cut more functionality like tracing, alert and remote storage, however, it will take more effort to maintain and make sure all the tests will be passed. The related changes can be found here https://github.com/wejick/ prometheus/commit/6dd776019a315764a9f70147f83f1235b9b13189 Share this: * Facebook * Twitter * Print * More * * Email * Tumblr * * Like this: Like Loading... Related This entry was posted in Note and tagged prometheus. Bookmark the permalink. Post navigation - Kegelisahan One thought on "Can I have a smaller Prometheus" 1. Pingback: More than 70% of prometheus executable are unused by most people - The web development company Lzo Media - Senior Backend Developer Leave a Reply Enter your comment here... [ ] Fill in your details below or click an icon to log in: * * * * * Gravatar Email (required) (Address never made public) [ ] Name (required) [ ] Website [ ] WordPress.com Logo You are commenting using your WordPress.com account. ( Log Out / Change ) Google photo You are commenting using your Google account. ( Log Out / Change ) Twitter picture You are commenting using your Twitter account. ( Log Out / Change ) Facebook photo You are commenting using your Facebook account. ( Log Out / Change ) Cancel Connecting to %s [ ] Notify me of new comments via email. [ ] Notify me of new posts via email. [Post Comment] [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] Search [ ] [Search] linux registered user 462174 Archives Archives [Select Month ] Categories * Electronics * Linux * Literacy * Note * Programming * Tought Recent Posts * Can I have a smaller Prometheus * Kegelisahan * Di antara * (no title) * Antara pendidikan dan pengembangan karir Tulisan Teratas * Can I have a smaller Prometheus * Sejarahku * Intercepting Http Response writer in Go * Di antara * Membuat File Server sederhana berbasis Http Recent Comments More than 70% of pro... on Can I have a smaller Prom... yoen on Di antara wejick on Sebuah kotak 40 meter per... Blog at WordPress.com. [Close and accept] Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy * Follow Following + [wpcom-] In My Honest Opinion Join 1,796 other followers [ ] Sign me up + Already have a WordPress.com account? Log in now. * + [wpcom-] In My Honest Opinion + Customize + Follow Following + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar Loading Comments... Write a Comment... [ ] Email (Required) [ ] Name (Required) [ ] Website [ ] [Post Comment] Send to Email Address [ ] Your Name [ ] Your Email Address [ ] [ ] loading [Send Email] Cancel Post was not sent - check your email addresses! Email check failed, please try again Sorry, your blog cannot share posts by email. %d bloggers like this: [b]