The pragmatic architecture of my production projects

Reading some discussions between developers or software architects, one might think that the smallest web application today requires a distributed infrastructure, a Kubernetes environment and several specialized cloud services.

Yet many web services, including those that receive several thousand visitors per day, work just as well with a simpler architecture.

Here is an account of the infrastructure behind my production projects, some of which exceed 5,000 daily visitors. I also applied it for years to a cybersecurity competition with more than 250 participants in real time.

Context

For years, I hosted all my projects directly at home. My websites, my services, my Git forge and even my continuous integration infrastructure ran on small ARM machines: mainly Pine64 boards, but not only.

Contrary to what I often read, it all worked well.

I did not stop because of a lack of computing power or reliability, but simply because I moved to a more nomadic lifestyle. A stable, permanent residential connection becomes hard to guarantee when you travel often.

My solution was to move the public-facing part of my services to OVH, while keeping the same philosophy: simplicity and pragmatism.

Content that rarely changes

Many modern web projects adopt an architecture similar to this one:

browser → CDN → frontend → API → database

Every request triggers server-side computation, even though the main content rarely changes. This requires many machines and sometimes involves several providers. Above all, if a single one of these components fails, the content can no longer be served.

Many blogs, including this one, are on the contrary served directly by a web server, with no generation step and no complex caching mechanism. The pages are generated before publication: once and for all.

The vast majority of websites that mainly present content could be simplified in the same way: online newspapers, company showcases, online shops, …

For example, I publish a daily Yakazu game. For most visitors, the only thing that matters is the grid of the day. Yet this content changes only once a day: generating the page dynamically on every request therefore does not make much sense.

Chosen architecture

I therefore made the site mostly static.

Every day, an event triggers the rebuild of the site, then pushes the new files to the space provided by the hosting company. These files are served directly to visitors, the only intermediary being the static hosting included with the domain name at OVH.

Yes, this free 100 MB plan, which looks microscopic and unusable, can actually host a shop where users are happy to come back every day.

All the traffic is absorbed by the provider’s infrastructure, which is precisely what it is designed for.

Page generation

The site is built with SvelteKit.

This choice may seem surprising, since I do not use the server-side capabilities of this tool. It nevertheless makes it possible to:

  • easily generate a static site (@sveltejs/adapter-static);
  • structure the code;
  • get clean routing;
  • build Progressive Web Apps.

When a dynamic part is needed

Some features still require a bit of server-side logic. For instance, the championships held regularly need to verify participations, then record results and times.

In that case, I start a small separate server, which only receives a limited number of requests. The architecture then becomes:

browser → static site
 (CORS) → backend

This backend is deliberately minimal and only handles the actions that are truly indispensable. Most of the traffic therefore never reaches it.

User accounts and payments

Why would a “login” to a user account need systematic validation by the server?

A single API request is enough for authentication, whether it validates a payment or an email address. The response is then stored in the browser, to be used in the interface right away … or later! There is no need to query the API again for information that is already known.

On the one hand, the server load is reduced. On the other hand, loading is faster for the user, who sees their data without a network call, even offline. Everyone wins!

Is an account really necessary?

The account creation step often has no justification at all: when a player wants to buy more Yakazu grids, they want to play, not come up with a new password.

No technical barrier prevents giving access to content in exchange for a simple payment.

If the payment is used to collect an identifying piece of personal data (email address, phone number, Apple or Google account for Apple Pay or Google Pay, …), that same data can later be used to give access to the content again, this time after authentication (with a magic link, for example).

Results

With this architecture:

  • almost all the traffic is served as files;
  • the computing power needed on the server side is ridiculously low;
  • the failure surface is small.

The problems I run into are almost always related to the generation process:

  • a trigger that fails;
  • an outdated Docker image;
  • something missing in the data generation (the absence of a game grid, for example).

These problems are however easy to detect and are usually fixed within minutes.

The rules I take from it

After several years, I notice that this approach comes down to 3 rules:

  1. pre-compute what can be pre-computed;
  2. serve files rather than computation;
  3. keep computation for the cases that truly need it.

They make it possible to absorb a significant load with modest human and material means.

Applying it to a mostly dynamic service

Some services necessarily rely on a server-side computation or generation step. There is nothing wrong with that: the content presented depends on factors that go beyond the user alone.

For more than ten years, I organized a cybersecurity challenge with modest machines. With nearly 300 simultaneous participants in the last years, the architecture had to handle the load and withstand the software attacks that were likely to happen: a challenge that goes far beyond what most websites will ever face.

It held thanks to the design of the system, not to the power of the hardware. I detailed this infrastructure in a presentation (in French), with its constraints, my trial and error, my mistakes and the successes that shaped it.

Conclusion

Before adding a new technological layer to a project, I encourage you to ask yourself the following question: does this content really need to be generated on every request? In many cases, the answer is no.

I come back to the reasons that push towards heavier architectures anyway in another article.