concept NetKernel in category nosql

appears as: NetKernel
Making Sense of NoSQL

This is an excerpt from Manning's book Making Sense of NoSQL.

NetKernel knows what functions are called with what input data, and uses a URI to identify if the function has already generated results for the same input data. NetKernel also tracks URI dependencies, only re-executing functions when input data changes. This process is known as the golden thread pattern. To illustrate, think of hanging your clean clothes out on a clothes line. If the clothes line breaks, the clothes fall to the ground and must be washed again. Similarly, if an input item changes at a low level of a dependency tree, all the items that depend on its content must be regenerated.

NetKernel automatically regenerates content for internal resources in its cache and can poll external resource timestamps to see if they’ve changed. To determine if any resources have changed, NetKernel uses an XRL file (an XML file used to track resource dependencies) and a combination of polling and expiration timestamps.

10.2.2. Using NetKernel to optimize component regeneration

The NetKernel system takes a systematic approach to tracking what’s in your cache and what should be regenerated. Instead of using hashed values for keys, NetKernel constructs URIs that are associated with a dependency tree and uses models that calculate the effort to regenerate content. NetKernel performs smart cache-content optimization and creates cache-eviction strategies by looking at the total amount of work it takes to generate a resource. NetKernel uses an ROC approach to determine the total effort required to generate a resource. Though ROC is a term specific to NetKernel, it signifies a different class of computing concepts that challenge you to reflect on how computation is done.

Figure 10.13. NetKernel works similarly to a memcache system that separates the application from the database. Unlike memcache, it’s tightly coupled with the layer that’s built around logical URIs and tracks dependencies of expensive calculations of objects that can be cached.

As you can see from figure 10.13, the NetKernel software is layered between two layers of resources and services. Resources can be thought of as static documents, and services as dynamic queries. This means that moving toward a service-oriented intermediate layer between your database and your application is critical to the optimization process. You can still use NetKernel and traditional, consistent hashing without a service layer, but you won’t get the same level of clever caching that the ROC approach gives you.

By using ROC, NetKernel takes REST concepts to a level beyond caching images or documents on your web server. Your cache is no longer subject to a simple timestamped eviction policy, and the most valuable items remain in cache. NetKernel can be configured to use complex algorithms to calculate the total effort it takes to put an item in cache, and only evicts items that have a low amount of effort to regenerate or are unlikely to be needed. To get the most benefits, a service-oriented REST approach should be used, and those services need to be powered by functions that return data with referential transparency. You can only begin this journey if your system is truly free from side effects, and this implies you may need to take a close look at the languages your systems use.

In summary, if you associate URIs with the output of referentially transparent functions and services, frameworks such as NetKernel can bring the following benefits: