{"_id":"566226ed0299ea0d008f2cee","user":"54d4ec36f6c48a0d00f0f040","category":{"_id":"56620e60f183880d004d3217","version":"563a2dba1846790d00895309","__v":2,"pages":["56620ebbb401c70d00dde7aa","566226ed0299ea0d008f2cee"],"project":"54d4ecb5f6c48a0d00f0f041","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-04T22:06:24.370Z","from_sync":false,"order":1,"slug":"counter-sharding","title":"Counter Sharding Basics"},"version":{"_id":"563a2dba1846790d00895309","__v":3,"project":"54d4ecb5f6c48a0d00f0f041","createdAt":"2015-11-04T16:09:30.844Z","releaseDate":"2015-11-04T16:09:30.844Z","categories":["563a2dbb1846790d0089530a","563a2dbb1846790d0089530b","563a2dbb1846790d0089530c","56620e60f183880d004d3217","5702e5b8f2d6f336005e9025"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"No Mashape","version_clean":"1.1.0","version":"1.1"},"__v":10,"project":"54d4ecb5f6c48a0d00f0f041","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-04T23:51:09.025Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"You bet your beans they can!\n\nUsing counter shards, it becomes possible to horizontally scale any counter by simply increasing the number of shards available for incrementing or decrementing.\n\nIn the case of Instacount, we use Google data persistence technology which provides us with roughly 5 operations per second, per shard.  Thus, a counter with 10 shards would be able to support ~50 operations/second; a counter with 100 shards would be able to support ~500 operations/second; and so on.\n\nTo put this into perspective, one of the most popular videos ever posted on YouTube was \"GANGNAM STYLE\" by Psy, which as of this writing has received [more than 2.4 billion views on YouTube](https://www.youtube.com/watch?v=9bZkp7q19f0).\n\nHowever, quickly after this video was posted in July of 2012, it became wildly popular, garnering nearly 1 billion views by December of that year!\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/L8RyIRN7RYK071Kyo5XW_psy.png\",\n        \"psy.png\",\n        \"1600\",\n        \"500\",\n        \"#3cacf4\",\n        \"\"\n      ],\n      \"caption\": \"Video views (in millions) of \\\"Ghangam Style\\\" on YouTube (July - December, 2012)\"\n    }\n  ]\n}\n[/block]\nIf YouTube had been using Instacount to track these views over those first six months, they would have been incrementing a single counter approximately 65 times per second.  This is well within the threshold of Instacount -- it would have only required about **13 shards** (*65 increments per second for roughly 15m seconds, or about 6 months for a total of ~1B increments*).\n\nOver the next nearly 36 months from January 2013 to the present, handling the remaining 1.4 billion page view increments would have required only about **3 to 4 shards** (*~15 increments per second for roughly 93m seconds, or about 36 months*).\n\nIn truth, if a counter's count is expected to reach into the billions, it would likely be a waste of resources to increment the same counter 1 billion times using a high-accuracy counter like an Instacount Sharded counter.  Instead, an approximated counter might be more appropriate.  However, this example is used to show that a sharded counter could theoretically handle such a load.","excerpt":"Can a Sharded Counter handle the most demanding applications in the world?","slug":"how-scalable-is-a-sharded-counter","type":"basic","title":"How Scalable Are They?"}

How Scalable Are They?

Can a Sharded Counter handle the most demanding applications in the world?

You bet your beans they can! Using counter shards, it becomes possible to horizontally scale any counter by simply increasing the number of shards available for incrementing or decrementing. In the case of Instacount, we use Google data persistence technology which provides us with roughly 5 operations per second, per shard. Thus, a counter with 10 shards would be able to support ~50 operations/second; a counter with 100 shards would be able to support ~500 operations/second; and so on. To put this into perspective, one of the most popular videos ever posted on YouTube was "GANGNAM STYLE" by Psy, which as of this writing has received [more than 2.4 billion views on YouTube](https://www.youtube.com/watch?v=9bZkp7q19f0). However, quickly after this video was posted in July of 2012, it became wildly popular, garnering nearly 1 billion views by December of that year! [block:image] { "images": [ { "image": [ "https://files.readme.io/L8RyIRN7RYK071Kyo5XW_psy.png", "psy.png", "1600", "500", "#3cacf4", "" ], "caption": "Video views (in millions) of \"Ghangam Style\" on YouTube (July - December, 2012)" } ] } [/block] If YouTube had been using Instacount to track these views over those first six months, they would have been incrementing a single counter approximately 65 times per second. This is well within the threshold of Instacount -- it would have only required about **13 shards** (*65 increments per second for roughly 15m seconds, or about 6 months for a total of ~1B increments*). Over the next nearly 36 months from January 2013 to the present, handling the remaining 1.4 billion page view increments would have required only about **3 to 4 shards** (*~15 increments per second for roughly 93m seconds, or about 36 months*). In truth, if a counter's count is expected to reach into the billions, it would likely be a waste of resources to increment the same counter 1 billion times using a high-accuracy counter like an Instacount Sharded counter. Instead, an approximated counter might be more appropriate. However, this example is used to show that a sharded counter could theoretically handle such a load.