avatar.com software

Summary

The content discusses the development of a modular monolith application in Symfony for a book store system, advocating for the use of a monolithic architecture over microservices for a startup due to its simplicity and ease of transformation into microservices when the business scales.

Abstract

The website content presents an argument for choosing a modular monolith architecture over the trendy microservices for a new SaaS startup. It acknowledges the popularity of microservices but points out the complexities and potential pitfalls associated with this architecture, especially for a startup with limited resources. The author suggests that a well-structured monolith can be an excellent starting point, allowing for an easier transition to microservices if and when the business grows and can support the added complexity. The proposed application is a book store system that will be developed using PHP 8 and Symfony 6, with features such as browsing books, user registration, book purchases with postal delivery, email receipts, and notifications for book availability. The project will enforce module independence using Deptrac.

Opinions

  • The author believes that microservices are overhyped and can lead to increased complexity and costs that are not justified for a startup.
  • A well-written monolithic application is preferred for its simplicity in development, deployment, and maintenance, especially in the early stages of a business.
  • The transformation from a monolithic to a microservice architecture should be smooth if the monolith is properly modularized.
  • The author emphasizes the importance of having truly independent modules within a monolithic architecture to facilitate future changes.
  • The article suggests that the decision to adopt microservices should be made when the business has the necessary resources, namely people and money.
  • Despite the current trend favoring microservices, the author advocates for the value of monolithic architecture in certain scenarios.

Modular Monolith Application in Symfony

A truly modular monolith application project in PHP

Photo by Randy Fath on Unsplash

What software architecture would you choose if you were to launch a SaaS startup today? I bet the first thing that comes to your mind is an architecture based on microservices.

There is no serious programming conference these days without at least one topic related to microservices.

No wonder; the topic is so overhyped nowadays:

Microservices” keyword popularity by Google Trends

Many companies embraced such architecture and died in the run. You are going to find a lot of great stories how microservices went wrong for some entrepreneurs.

Netflix started as a simple DVD movie rental system. They did not become the powerful system that we know overnight. It was a process; and it took many years to develop. From a monolith-based application to this monster:

Netflix’s microservice architecture by Bruce Wong

The microservice architecture is, well, hard.

Microservices are supposed to be independent of each other. There are no microservices if they share a database or some other resource.

With five microservices, we are talking about five separate database servers, five Redis instances, five reverse proxy servers, five PHP-FPM processes, etc. And I haven’t even touched the High-Availability topic yet.

There are increasing issues with: debugging, latency, deployment, infrastructure, infrastructure costs, logging, monitoring, service discovery, access management, cost management, etc. The costs rise exponentially.

I do not think a starting business needs such complexity. A correctly written monolithic application is a breeze to work on and deploy.

When starting a business, you want to launch with an MVP. If the venture works out and starts earning serious money, there is nothing to prevent a monolithic project from transforming into a microservice-based architecture. Only then do you have the means to run such architecture: people and money.

In a well-written, high-quality monolith application, such transformation should be painless; as long as the modules are truly independent.

Why does hardly anyone today appreciate monolithic architecture?

How about we try to design such a modular monolith from scratch?

The idea for the application

Photo by YJ Lee on Unsplash

I am not earning enough on Medium to spend too much time on this project (claps won’t feed my kids, will they?)

Still, I would like it to be somewhat practical: a book store system — a domain that probably all of us are familiar with.

Let’s define some goals, shall we? It would be a web-based application written in PHP 8, based on Symfony 6:

  • where people could browse books,
  • register and buy books,
  • books would be delivered by post,
  • the buyer would receive a receipt by e-mail,
  • people could be notified when a book becomes available to purchase,
  • composed of independent modules with boundaries enforced by Deptrac.

Well, I got a bit carried away, but I already love the idea and I am thrilled to start coding. You know the feeling, right?

I will notify you promptly when I start working on the project. I sincerely hope it’s going to be a useful resource for you.

Symfony
PHP
Development
Programming
Php Developers
Recommended from ReadMedium