2020-06-01 at

Web Apps on FaaS: Six Weeks In (after Six Years Away)

I just realised two things about web development in 2020.

(1.) A lot of web application frameworks now assume responsibility for being HTTP (web) servers also. 

Initially, web servers were designed to serve static content. Then, people started serving dynamic content, and because language runtimes didn't come out of the box with HTTP servers, you typically had this kludge of middleware between a language runtime and a specialised web server program (the driver).

But now it is de rigueur that scripting languages must treat HTTP as a first-class environment, and so language runtimes are much more supportive of HTTP out of the box, leading us to gradually reduce reliance on specialised web server programs. The old web server layer has basically become absorbed by the old web application framework layer, and now they are often (but not always) the same thing.

This is particularly true of web-first language runtimes, like NodeJS and Go. Furtheronto this is the common trait: web application frameworks today have an opinionated approach to parsing HTTP. 

 (2.) FaaS throws a wrench into this. Functions as a service are basically ways to carve up vCPU time ... but their implementations range from being specialised in one web application runtime, to being web-application runtime-agnostic. In the latter case, this means that FaaS implementors have to pick some lower-level abstraction, which at this point in history, turns out to be typically (2.1.) a cGroups-type Linux containers (I haven't yet figured out what MSFT is doing in Azure Functions), with (2.2.) some sort of gateway/reverse proxy sitting in front of the former. So now F/PaaS providers are inserting themselves in a very minimal fashion as dependencies because there doesn't yet exist any common vendor-agnostic consensus on how to implement a F/PaaS. Nearly all of them have an opinionated approach to parsing HTTP.

Now as a web application developer, I want to be able to use FaaS without being overly concerned about vendor lock-in. However given that each FaaS vendor provides different host runtimes, we now need to write our applications in a way that is decoupled from those idiosyncrasies. Which brings me to my main point: FaaS web application frameworks are a strange beast. They have to address the following:

 ... oh where do we begin, close to or far from the metal? Let's begin closer to the metal:

(A) sufficient abstraction over operating system and kernel variables; fortunately this is largely handled by ...

(B) ... the language runtimes, whether they are compiler or interpreter oriented, they typically now all offer some sort of low-level virtual machine (not to be confused with The LLVM);

(C) ... THE VENDOR'S GATEWAY/REVERSE PROXY's opinion about how HTTP should be handled; that is to say, how you get your request data, and how you return your response data, will vary based on which cloud you are using at the moment;

(D) and finally, if you happen to be basing your FaaS web application framework on some PRE-FAAS WEB APPLICATION FRAMEWORK, then be prepared to have to abstract over ITS opinions about how HTTP should be processed. 

In summary, this is going to be a problem most FaaS developers can ignore. Using any D usually wraps up all the complexity of { A, B, D }, leaving us to figure out how to glue those all to C, which usually doesn't take too long. 

But what if we want to write a framework that abstracts over all of { A, B, C, D }? Well that seems to be a little more challenging. And that's what I'm thinking about today.

Periodic Re-risking

/was commenting in a forum on questions people need to ask themselves in managing their personal finances; my suggestion was that people need to periodically ask themselves if they're taking too little risk - some might find it is true, then save less and spend more on projects/

My background: my folks are super conservative, highly educated, class-conscious, non-business-oriented types. So the way I was raised, and given some more privilege in terms of aptitude ... I had all the tools to stay in the top quartile of the population class/pyramid just by getting and holding down the right kinds of jobs ... this wasn't even a question the entire time I was raised.

My own interest therefore, is in commerce - because it's stuff I don't think I grew up with a lot of knowledge about. I had other priorities marked out until the end of my first degree, so even when professors asked me to do little jobs like "I have some data in Excel that needs doing" I would just tell them "I haven't studied Excel", and they would be like "oh, ok".

Anyway, following my plan, after graduation (2005) I focused on deprioritising non-commercial studies, so that I could focus on commerce (and Malaysian political economy, but that's another story).

After a few years (2012) I found myself too comfortable again. I could just sit at home trading for a few minutes a day on the KLSE (this is not even a high-growth market) and double my ~40k small monies in a few months, while I spent most of my time studying other things. It was at this point that I decided to start discarding money again ... I never had a business environment to play in when I was growing up, and I was aware that business people need to be comfortable taking losses, in order to be able to approach large opportunities. At this point I basically told myself it was OK to torch the whole trading portfolio, just for the experience of it. And that's basically what I did over the next few months - I just let it sit there, and (since most of it was in options), the time value decayed to near zero.

That was one of the big learnings for me - I'm still building on it. I'm still looking for more commercial stuff to learn. I'm not sure if this counts as personal finance, so I don't talk about it all that much ... also I don't think it's relevant to most readers who are usually coming from the other end, and always worried that they have too little money.

I've "had too much" since I was in college ...

2020-05-27 at

HTTP key-value semantics

omg, my life has been a lie
Well, anyway, I just figured out some grown-up stuff, and I guess I should write it down while it's fresh. So in HTTP:
  • query string parameters (key-value)
  • cookie header parameters (name-value)
  • form string parameters (name-value)
  • ... (not sure if I missed anything else)
First of all, notice that the labels in all of these categories are not consistently termed. Some of their RFCs refer to the label as a 'key', and others refer to the label as a 'name'.

Second, and more importantly, each of these categories ALLOWS REDUNDANT LABELS, which is to say, you can have multiple instances of the same label per HTTP request, and therefore you can have multiple values under each label ... and therefore ...
... every single web application which auto-magically parses a HTTP request and defaults to passing a label-scalar instead of a label-array is a lie.
The semantically correct treatment for this should be label-array and it should be up to the developer to check the length of the array, before making use of the data in their application. Of course, you could argue that the point of frameworks is to reduce such boilerplate. But then I would just say that some frameworks are more obfuscating than others.

A protocol is a protocol. You can have frameworks that make protocols easier to work with, but frameworks which obscure the nature of protocol are bad frameworks. Throw them away. 

This learning triggered me a bit. In a separate post I decided that in the future I must explore a complete refactoring of HTTP/HTML to a new set of protocols ... and the goal will be to see if we can make it more performant than HTTP/HTML while tunnelling it over HTTP/HTML for compliance.