{"id":86,"date":"2011-12-23T23:45:12","date_gmt":"2011-12-24T06:45:12","guid":{"rendered":"http:\/\/walkingideas.com\/blog\/?p=86"},"modified":"2011-12-24T04:23:50","modified_gmt":"2011-12-24T11:23:50","slug":"key-membase-stats-for-monitoring-and-how-to-get-them","status":"publish","type":"post","link":"https:\/\/walkingideas.com\/blog\/key-membase-stats-for-monitoring-and-how-to-get-them\/","title":{"rendered":"Key stats to monitor for your Membase cluster"},"content":{"rendered":"<p>Happy holidays everyone! \u00a0I realize that from working with Membase in our production over the last year, I&#8217;ve collected a few key commands in my .bashrc for quickly checking vital stats on my Membase servers, many of them came from the good folks at Couchbase. \u00a0 Their wiki has improved over the year as well, and you can find a lot of good information there. \u00a0Here I will list the most common commands I run for monitoring and troubleshooting, along with related links to the Membase wiki:<\/p>\n<p><!--more--><\/p>\n<p><strong>mbstats<\/strong> is the most useful utility that will print out all the important stats in the system. \u00a0Like I said, many of these stats are accessible via the web console. \u00a0But ultimately, if you want a script to periodically capture the data and alert if something goes wrong, you still want to keep this command handy:<\/p>\n<pre>\/opt\/membase\/bin\/mbstats \u00a0localhost:11210 all<\/pre>\n<p>When first growing out your database, it&#8217;s good to observe how quickly\u00a0<strong>mem_used <\/strong>approaches<strong> high_wat<\/strong>, which is when Membase will have to start ejecting data from memory, and subsequent read of ejected data will result in a disk read. \u00a0For animal party, we&#8217;ve been near high_wat for many months, but our working dataset is fairly small part of the entire data, so we don&#8217;t have a lot of disk reads. \u00a0But if you see your cluster is approaching high_wat quickly, start to keep a watch on how often server is fetching data from disk. \u00a0If you see the <strong>cache miss ratio<\/strong>\u00a0from the web console start to climb, then you should look into adding more memory to the cluster.<\/p>\n<p>For more detailed monitoring on the effect of cache miss, <strong>ep_bg_fetched<\/strong>\u00a0will tell the numbers disk fetches that has been performed since server was started. \u00a0You can pull the number twice with a time lapse in between to estimate disk fetches per second or minute to give you a stat to record and later compare. \u00a0Adding up\u00a0<strong>ep_bg_load_avg <\/strong>and<strong> ep_bg_wait_avg <\/strong>should tell you how long on average it takes an item to get loaded off the disk in microsecond, and if it starts to get too high you know you need to get more memory into the cluster to reduce ejecting item and subsequently reduce disk fetches.<\/p>\n<p><strong>eq_queue_size<\/strong>\u00a0and <strong>ep_flusher_todo<\/strong>\u00a0combine to tell you how many items are waiting to be written to the disk. \u00a0When an item needs to be written, it first gets added into a queue that goes towards the ep_queue_size count. \u00a0A dedicated disk writing process or processes (ala flusher) will on a periodic basis\u00a0take items out of this queue and write them to the disk. \u00a0 The items that are off the queue but have not made it onto the disk yet will be accounted for in ep_flusher_todo. \u00a0Obviously, you always want the disk queue to drain more quickly than it&#8217;s being filled, or server will run out of memory to store these pending items.<\/p>\n<p>In general, you don&#8217;t want the queue to be too large anyways, because that means you have a lot of data that are not persisted to disk. \u00a0Granted, they will be replicated in another node in the cluster, but if both the main copy and the replica copy are both stuck waiting in the disk queue and servers are rebooted, you would lose those data. \u00a0During a rebalance, you will see the disk queue shoot up dramatically, since data needs to be relocated to the appropriate node. \u00a0This is why I choose to schedule a downtime for the application during rebalance even though theoretically it can still serve data normally &#8211; all the new writes that are happening during a rebalance may take much longer than normal before they are persisted to disk, increasing the risk of losing those data.<\/p>\n<p>The Membase wiki has a good explanation on what stats to monitor and why:<a href=\"http:\/\/www.couchbase.org\/wiki\/display\/membase\/Ongoing+Monitoring+and+Maintenance\"><br \/>\nhttp:\/\/www.couchbase.org\/wiki\/display\/membase\/Ongoing+Monitoring+and+Maintenance<\/a><\/p>\n<p>As a reference, here&#8217;s a link for complete list of all the stats and what they mean:<br \/>\n<a href=\"https:\/\/github.com\/membase\/ep-engine\/blob\/master\/docs\/stats.org\">https:\/\/github.com\/membase\/ep-engine\/blob\/master\/docs\/stats.org<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>dispatcher<\/strong>\u00a0is another interesting command that gives you visibility into what Membase is actually doing at this moment. \u00a0You can run it with the following command:<\/p>\n<pre>\/opt\/membase\/bin\/mbstats localhost:11210 dispatcher logs<\/pre>\n<p>There are a few dispatchers, and to be frank, I don&#8217;t really know any details about them (you can read\u00a0<a href=\"http:\/\/www.couchbase.org\/wiki\/display\/membase\/DGM+Implementation+Details\">http:\/\/www.couchbase.org\/wiki\/display\/membase\/DGM+Implementation+Details<\/a>\u00a0if you are curious). \u00a0But for monitoring purpose, I look at the entries in the &#8220;Slow jobs&#8221; section. \u00a0 For example, this is one of the jobs that is returned in the dispatcher log:<\/p>\n<pre>        runtime:   2s\r\n        starttime: 43439\r\n        task:      Fetching item from disk:  StoryQuest40000001045816<\/pre>\n<p>So here I see that item &#8220;StoryQuest40000001045816&#8221; took 2 seconds to come off the disk, and the job was started at a time that is 43439 seconds after the server booted up. \u00a0If you didn&#8217;t see any recent slow jobs in the log, then you know things are doing fine. \u00a0If a task is taking a long time to finish, you may get an idea what is going on by looking at the description, but chances are you may need to get some support help from the Membase folks to decipher the issue.<\/p>\n<p>Last useful command is <strong>mbcollect_info<\/strong>, which is what folks at Membase always ask me to run whenever I report an issue. \u00a0Since I need to run this on all the nodes in the cluster and aggregate the output, I ended up adding this to a larger script so this can be automated.<\/p>\n<pre>\/opt\/membase\/bin\/mbcollect_<wbr>info FILENAME.zip<\/wbr><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<span id='mp-share-below-action'><\/span><ul class='mp-share-buttons'><li class='mp-share-buttons-fb'><div class='fb-like' data-href='https%3A%2F%2Fwalkingideas.com%2Fblog%2Fkey-membase-stats-for-monitoring-and-how-to-get-them%2F' data-width='' data-layout='button' data-action='like' data-size='small' data-share='true'><\/div><\/li><li class='mp-share-buttons-tw'><a class='twitter-share-button' href='https:\/\/twitter.com\/share'?url='https%3A%2F%2Fwalkingideas.com%2Fblog%2F%3Fp%3D86' data-via=''><\/a><\/li><\/ul><div class='mp-share-clear-fix'><\/div>","protected":false},"excerpt":{"rendered":"<p>Happy holidays everyone! \u00a0I realize that from working with Membase in our production over the last year, I&#8217;ve collected a few key commands in my .bashrc for quickly checking vital stats on my Membase servers, many of them came from the good folks at Couchbase. \u00a0 Their wiki has improved over the year as well, [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[15],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-development","tag-membase"],"_links":{"self":[{"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":6,"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":90,"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/posts\/86\/revisions\/90"}],"wp:attachment":[{"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingideas.com\/blog\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}