Blog-Icon_3_100x385

Those Pesky Supermarket Download Counts

Since the launch of Supermarket there has been the occasional question about how quickly the download counts grow for any given cookbook. In fact, if you upload an empty cookbook, it will quickly have greater than 10,000 downloads.

The download counter is ticked any time a cookbook is downloaded from the web interface or via the API. This is a change from the previous iteration of the community site which only tracked downloads that were the result of someone downloading the cookbook from the web interface.

Along came Berkshelf

To understand why the counters are what they are, there is a bit of history that is worth knowing. As Berkshelf, a cookbook dependency manager, evolved, it became necessary to maintain a better view of the world. What many of us know as the /universe endpoint today was created. This endpoint is fairly simple in nature; it provides a json representation of all the cookbooks, their versions and dependencies.

The problem was that there was no API for all that dependency information. The community site just didn’t provide it in the API. This left one possible way to solve this problem. The berkshelf-api server would need to download every cookbook on the community site, then extract and parse the metadata.json. Even worse, to keep the service up to date, it performed this exercise every five minutes by default.

The cool thing is, now that Supermarket has been released, a number of the issues around this are no longer the case. First, Supermarket now provides a /universe endpoint. In fact, it is the service that is providing support for api.berkshelf.com. Second, you can now get cookbook dependency information via the API provided by Supermarket. Finally, versions after 2.0.0 of the berkshelf-api server no longer download the cookbooks during each run and instead use the Supermarket API to get dependency information.

Fixing the Download Numbers

One of the things I have always appreciated about Chef is that we try very hard not to break other folks. No one likes to go do a berks install only to find out that their berkshelf-api server has fallen over. So, the way we fix this download count is by getting folks to upgrade their berkshelf-api server instances. This will not only help us get more accurate download numbers, but it will cause those berkshelf-api servers to run more efficiently since they are only querying an API instead of downloading all the cookbooks.

Posted in:

Christopher Webber