DEV Community

Cover image for Exploring Modern Architectures: A Shallow Dive into Modular Monoliths, Event-Driven Architecture, and Edge Computing
Rich McIntyre
Rich McIntyre

Posted on

Exploring Modern Architectures: A Shallow Dive into Modular Monoliths, Event-Driven Architecture, and Edge Computing

In an ever changing technical landscape, modern architectures are becoming increasingly important for businesses to stay competitive and efficient. Getting your architecture right is the difference between scaling and delivering fast with longevity and not. So, you need to make good choices.
I often help organisations look at the architecture patterns they employ, and together think about technical strategic opportunities. In one of these recent sessions, there were 3 brilliant architectural approaches that I thought it would be worth sharing.

Modular Monoliths: The Best of Both Worlds

Ever had challenges with micro-service network complexity and deployment orchestration? Ever found a large evolving monolith turn into spaghetti with slow cumbersome test cycles and functionality bloat that becomes hard to understand?

Modular Monoliths
I first came across the modular monoliths through the excellent Elixir programming language, they have a concept of 'umbrella projects', that you can set up through its default build tool 'Mix'.
As a developer I would often introduce modules immediately as I set up an app. This would allow me and the team I was working with to very clearly work within the domain boundaries, and to easily separate the logic into a brand-new service should I need to. Recognising shared logic and domain specific logic and creating a logical separation early, helps you to create elegant, maintainable apps.
Each module will have clear entry points through its router, you do not access other modules apart from via it's routing mechanism, this is to ensure that you do not re-create a spaghetti monolith by accident.
You can then either deploy the application as a monolith, if you need to future separation, you can have some routing logic that will allow subdomains to map to paths, so externally they appear like individual services. You can also deploy to multiple compute instances and despite services all having the save code deployed to them, similar domain to path mapping can ensure each service only invokes the module that is dedicated to a given domain.

We have found the benefits of a Modular Monolith include:

  • Single or multiple deployment units
  • Less Operational Overhead
  • Separation of Concerns
  • Focused Ownership
  • No Network Latency
  • Optimized Resource Usage
  • Selective & Efficient Scaling
  • Reduced Infrastructure Costs
  • Potential Lower Development Costs

Modular Monoliths offer a balanced approach, combining the simplicity of monolithic architecture with the flexibility of micro-services. This pattern allows developers to build applications as a single, cohesive unit while maintaining clear boundaries between different modules. This approach not only simplifies deployment but also enhances maintainability and scalability.

Event-Driven Architecture: Events as a first-class citizen

We often have events within our architectures, however are they truly event-driven? What is the difference between utilising events being event-driven?

Event Driven Architecture
One way that you might think about this problem, is to take out all other communication methods such as REST from the internal communication of your system, would it still work? One reason micro-service architecture has been seen as brittle and not fault tolerant, is its high reliance on HTTP. HTTP is great, it scales the entire internet. However, failure patterns are not very elegant and are often not implemented consistently.
Event-driven architecture (EDA) is a powerful pattern where components communicate to each other primarily through events, EDA enables loose coupling and asynchronous communication providing fault tolerance and greater control of failure scenarios.
This is especially useful when you have many inconsistent dependencies, your messaging service can handle much of the abstraction for you, where the common language of communication of the service is the event message itself. Event streaming technologies such as Kafka or Azure's Service Bus, allow you to register message schemas, that be used for validation.

Some of the benefits include:

  • Loose Coupling
  • Independent Development
  • Asynchronous Communication
  • Focused Ownership
  • Fault Tolerance
  • Retry Mechanisms are easier to implement
  • Easier Interfacing
  • Parallel Processing

One of the key advantages of EDA is its ability to handle high availability services at a national scale. For example, in government projects, event-driven systems ensure that critical events, such as passport applications, are processed reliably and efficiently. This architecture also supports parallel processing making it ideal for systems that evolve frequently.

Edge Computing: Bringing Processing Closer to the User

Edge computing turns upside down the way we think about compute, deployment and cloud platforms.
Edge Computing
By moving computation closer to data sources and user, edge computing reduces latency, makes systems feel more responsive and enhance the user experience. This is particularly useful for applications that require close to real-time processing and low latency.
In practice, edge computing has been used to create super-fast and efficient micro apps that can be deployed to the edge network. This not only improves performance but also simplifies deployment and management. However, there are still challenges, for example data centralisation (see this excellent blog post from Alex Mitchell), which need to be addressed to fully run with this

Some other benefits we have found:

  • Extremely cost effective
  • Intelligent Web Application Firewall (WAF) built in (Cloudflare)
  • Performant (we have seen sub 10 millisecond responses from workers)
  • Fast to deploy
  • All the good sides of Serverless (Scalability, cost, no maintenance)

We have found Cloudflare workers particularly effective, deployment times are extremely fast and the supporting features around it, including KV stores, databases and queues make them very powerful. In some cases, it might be possible to use Cloudflare as a cloud platform in itself.

Conclusion

Modern architectures like modular monoliths, event-driven architecture, and edge computing are evolving the way we build and deploy software. By understanding and implementing these patterns, businesses can achieve greater scalability, fault tolerance, and efficiency. As we explore these exciting approaches further, it's clear there will be some powerful solutions available to us in software development.

Top comments (0)