Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afoysal's avatar

MicroService Architecture

What are the benefits of MicroService Architecture ? How can I implement MicroService Architecture using Laravel ?

0 likes
11 replies
JussiMannisto's avatar

I'd say forget the term. Figure out what your app needs to do, then consider what's the best way of doing it. If in the end the pieces look like microservices, then by all means, call them microservices in your meetings. But the label doesn't matter.

The reason why I dislike the word is not that I dislike microservices. Sometimes it makes sense to break up parts of your architecture. But it's really bad to think in terms of labels rather than actual needs.

FWIW, you implement microservices with Laravel just like with anything else. You create a bunch of small apps instead of a single monolithic app, then have them communicate with each other. As for the benefits and drawbacks, use google and think about it.

If you're unsure if you need microservices, you don't.

2 likes
Lumethys's avatar

@JussiMannisto slight correction: the bunch of small apps communicate with each other asynchorously, if they communicate synchronously, i.e. with HTTP call or gRPC, then it is a modular monolith

JussiMannisto's avatar

@Lumethys I don't know how you're coming up with these definitions. It makes no difference whether it's synchronous or asynchronous.

Lumethys's avatar

@JussiMannisto well i'm not the one who made the definition, but the asynchronous or synchronous communication is THE biggest difference.

Most of the complexity and the benefits of microservices lies in the fact that it is communicating asynchronously with each other via a message broker. Take a look at the concepts and the patterns, the eventual consistency concept, the outbox pattern,... or the message delivery guarantee: at most one, at least one, exactly one; or the message order problem,....

Although we can "just" classified it as "communicate async or sync", the 2 of them require completely different architecture to achieve. You cannot "switch" between them without rewrite 60-70% of your app, if not more.

JussiMannisto's avatar

@Lumethys

well i'm not the one who made the definition, but the asynchronous or synchronous communication is THE biggest difference.

That's not at all what is meant by microservice in the industry. A microservice is something that:

  1. Is developed and deployed independently.
  2. Is autonomous and loosely coupled.
  3. Has a small and specific role.

That's all.

Most microservices on the web communicate through HTTP. Why would using HTTP make an architecture monolithic? Conversely, why would asynchronous messaging make it suddenly not monolithic?

1 like
Lumethys's avatar

@JussiMannisto the only way to truly decouple services, i.e. to satisfy your 3 points, is to make them communicate asynchronously.

Say, you have a monolith that have something like this:

$product = $this->productService->getProductBySomeCondition(.....);
$isProductAvailable = $this->inventoryService->checkAvailability($product->id);

you decide to split the Inventory part and the metadata part to "independent" services:

$product = $this->productClient->get('/details', [ 'conditions' => [....] ]);
$isProductAvailable = $this->inventoryClient->get("/product/availability/{$id}");

Now the Product Api is a whole different codebase and Inventory Api is a whole different codebase. We have achieve microservices, right? nope.

All the services is dependent on each other.

What if /details changes the response data? what if it change the parameter?

What if one of these service are down? what if multiple services are down?

The answer is simple: the whole system fail.

Look: Any business changes will require redeployment of ALL of the involved services. Imagine you have 10 services calling the Product microservices. Now the business changes and the data of a product have an additional 5 fields. What happen then? All 10 services must adjust their code and redeploy, no?

No:

  1. Is developed and deployed independently.

not possible with synchronous communication. Changes incur redeploy on all fronts

  1. Is autonomous and loosely coupled.

not possible with synchronous communication. Even if you do fire-and-forget, services must at least know: auth, endpoint, and input parameter of each other. Not "loosely coupled"

  1. Has a small and specific role.

As soon as a service call another. They are dependent on that service and inflate their role.

Why would using HTTP make an architecture monolithic

Why would asynchronous messaging make it suddenly not monolithic

Say, you have 10 services. 9 crashed for 1 hour. Can you make sure that in this 1 hour, all requests to that 1 living service succeed. And, after that 1 hour, after the other 9 come back up, they all receive their appropriate "notification" and process all the data they missed in that 1 hour? With just HTTP?

You can with the outbox pattern with a persistent message broker. Btw it is one of the application of the "eventual consistency" concept

The whole point of a microservices system is that each microservice doesnt even know about each other, even their existence. HTTP request by definition need the caller to know about the called's existence so that's a big difference. The services publish an event, or "announce" the something has been done, to a central dashboard, in this case, a message broker. Every other service can access this "dashboard" and decide if they need to do something based on stuffs posted on there. The one who publish it, however, does not care if who, or anyone do what, or not do what, in reaction to what they posted.

What this achieve is each services is truly coupled. They dont need to know or care about any other service, they had only 2 jobs: do their task, and publish the event after that task is done. Every other service can crash and burn and disappear, doesnt matter (to that service). Every other service can update specs, can rebuilt their service from scratch, can change server, change domain, change framework, change language, reconstruct their whole database,... and it doesnt affect your service in the slightest

if you want to learn more, there's this comment that can give more direction on the various concepts of Service-Oriented Architecture (SoA), microservices, event-driven architecture,....

Lumethys's avatar

@JussiMannisto just to be clear, im not disagreeing with your recommendation to OP, as I would do the same, i just point out that your definition is a bit off, as with most people

martinbean's avatar

@afoysal Instead of having one application to maintain, develop features in, and fix bugs in you have many.

The “benefit” of microservices is that if you have discreet services, you can build them in technologies that are maybe more suited to whatever problem you’re trying to solve with an independent service, and scale them independently of each other.

Unfortunately most people decide to just arbitrary carve a monolith into many applications, and then complain about latency because they’ve moved their joins and relations from the database, to be over network calls instead. If you also have more services than developers, that’s a red flag too.

I’d confidently say that 90% of applications that adopt microservices didn’t need them. And if you’re building microservices, then you wouldn’t use a batteries-included, full stack framework like Laravel to do so. That kinda defeats the definition of micro services to me.

4 likes
Tray2's avatar

@afoysal I agree with both @jussimannisto and @martinbean, it's very likely that you won't need to break your application inte microservices (One of those buzz words that managers loves, but doesn't understand the meaning of).

I'm not a fan at all of them, but they serve their purpose if, and only if they are easy to replace, aka loosely coupled to the rest of your application. You should be able to switch from one to another and no one will notice the difference.

However I still say that you should try to stay away from them, they add complexity to your application making it much harder to find the issue when something goes wrong.

1 like
martinbean's avatar

@Tray2 Indeed. For all of the problems microservices are claimed to solve, adopting them introduces entirely new—and far more complicated—problems to your project 😅

Tray2's avatar

@martinbean Agreed. We have this kind of setup at work.

System A -> System B -> System C -> System D

If the signal between A and B doesn't work, the symptom shows in D, and we back track fairly quickly.

I can just imagine that with 10 to 15 Microservices, and to remember which talks to which and in what order, no thank you.

Please or to participate in this conversation.