Postulating Extreme Web UI Scalability
I’ve been working with CQRS for almost a year. Ever since I first heard about it, I was immediately convinced that it had the ability to vastly simplify a lot of unnecessary development overhead. In this particular post, I will not be discussing event sourcing which is often mingled with CQRS. Instead, I will be focusing on the query side of the equation.
Please note that the ideas contained herein are merely conjectures of what might be rather than any kind of working, concrete implementation. I’ve thought my way through some aspects and ramifications of implementing what I mention below but new insights will undoubtedly merit additional consideration. Furthermore the solutions outlined below need not be considered mutually exclusive with more traditional ways of doing things. There is definitely room to implement portions of what I mention for specific views while doing things in the traditional way in other views.
Several weeks ago I blogged about having one table per view. Since that time Udi Dahan has mentioned it as well, although independently of my post. Querying view model tables directly, which comes as a positive consequence of implementing CQRS, enables us to avoid having numerous mapping layers between the database and the view. Further, it allows us to avoid projecting off of our domain model and keeps the domain model focused solely on behavior. Lastly, it allows us to scale the read database independently of the write database.
Content Delivery Networks
Think for a moment about the pure static resources that are handled on a given website. They just sit there with the exact same content for each request. These are the exact kinds of resources for which we could leverage a content-delivery network. In other words, we could push these static elements to a CDN and have the CDN deliver them for us thus offloading traffic from our servers and freeing our web tier to perform more interesting tasks—such as processing update-type commands. Not only does this offload work from our web tier, but the user has a better and faster browsing experience.
HTML + JSON
Static HTML Views + CDNs
The above has some interesting ramifications. Why couldn’t we just put the static HTML for each view into an HTML file and push those HTML files to a CDN? The static HTML files would have