Nexus Indexer 2.0: Save Bandwidth with Incremental Downloading

Nexus Indexer 2.0: Incremental Downloading

May 13, 2009
By Damian Bradicich

3 minute read time

The Nexus Indexer has become popular, and is the de-facto standard when it comes to indexing maven repositories (including the big boy, Central). As repositories grow and grow, the index of artifacts grows along with them. What was initially a small few hundred kilobyte file will grow into 20-30 megabytes or more over time. Seeing as the index is the gateway into the contents of a repository (not for maven mind you, but for users), this is the most downloaded file, and a 20mb file being downloaded by thousands of people every day, the bandwidth costs can get pretty high. To combat this, we have introduced incremental index handling into the Nexus Indexer. There are two parts, building the incremental indexes for consumers to download, and retrieving the incremental indexes from a provider.

Building Incremental Indexes

When the daily task runs on central to create indexes, the most recent content (in its entirety) is stored in the nexus-maven-repository-index.gz file. This file is always available as a fallback, if a consumer doesn't properly handle incremental indexes, or has fallen so far behind, that the provider no longer has all the incremental portions that the consumer needs. Alongside this, an incremental index is generated that contains all changes (adds/updates/deletes) since the last time the index was generated. This incremental file is very small, compared to the full index, most cases being ~10kb daily. These incremental files are listed in a nexus-maven-repository-index.properties file, along with a chain id. This chain id is used to 'reset' the incremental chain, should a full index download be required for some reason.

Retrieving Incremental Indexes

If the consumer application is integrated with the Nexus Indexer (at least version 2.0), there is nothing to worry about, the nexus-indexer will manage downloading the incremental pieces it is currently missing from the base. If anything does not line up (requires incremental pieces that the provider no longer carries, or the chain id is different), the indexer will then download the full index file and start checking for incremental changes next time it updates.

This is all handled in the nexus-maven-repository-index.properties file.

Support for Legacy Index Applications

Of course, we don't want to leave the legacy guys out in the cold, so the old timestamp based properties are also available:

So to wrap everything up, plain and simply, if your application is integrated with the nexus-indexer, you should definitely upgrade to 2.0.0, to get this enormous bandwidth saving. This has already been achieved with the latest m2eclipse 0.9.8 release, and will be coming in Sonatype Nexus Repository 1.4.

Written by Damian Bradicich
Damian is a software engineer at Sonatype. He is based in Connecticut.