Can we use Varnish as the backend?

In college, one of my favorite classes in college was a cloud networking class where we did a lot of work with programmable switches using P4, a domain-specific language for networking devices like routers and switches. The language was very limited in that you could not have loops or even do simple tasks like division, but these limitations allowed you to process packets at line rate. Using P4 to write custom switch logic, creative researchers have recently been able to figure out how to do a lot of interesting things like accelerate SQL queries or load balance servers.

I recently found out about Varnish and the Varnish Configuration Language (VCL), and it reminds me of P4. While switches deal with data on the network layer, a Varnish cache deals with HTTP requests on the application layer data. While programmable switches run P4, a domain-specific language that has limits in order to keep code fast, Varnish caches can run VCL, a domain-specific language that is also similarly limited (no loops) in order to keep code fast. That's why I think that there might be a lot more interesting things we could do with VCL in the future, and we can probably start by taking inspiration from researchers messing around with P4!

One interesting thought experiment I was thinking about was could we build a useful service that uses Varnish instead of a real origin? At my work, we like to write our backends in python, and we often use something like Flask. However, running python code can be very expensive, especially for microservices that may receive a lot of requests, so the logical conclusion here is to throw a cache in front, so that we don't have to run python code as often and requests hitting the cache are trivially cheap in comparison to requests hitting the origin. However, even in this case, cache misses, requests that are not GET, and requests with query strings will need to reach the origin. This brings me to the question: Are there services out there that are simple enough that might actually be better served if they had no origin and just ran out of Varnish? VCL offers us a bit of logic, so why not, right?

Comments

Popular posts from this blog

First-Principles Derivation of A Bank

A Play-by-play of the Mirai botnet source code - Part 1 (scanner.c)

You can control individual packets using WinDivert!