InterviewNoodle
Published in

InterviewNoodle

3 Common Software Architecture Patterns and When To Use Them

Have you ever thought about how software applications can scale? Is there any room to keep up with the user demands without affecting the whole system?
The deciding factor is the usage of a software architecture pattern that the application has implemented. Basically, a software architecture pattern refers to the fundamental structures of a software system and the discipline of creating such structures and systems. Each structure comprises software elements, relations among them, and properties of both elements and relations.

Bugs and limitations in a software application have an important impact on the business of an organization. The main reason for any software flaw can be at the application structure level. The selection of wrong architecture patterns can lead to major disfunction of the system, and can cause limitations in the company business in the long term.

Layered (n-tier) architecture

Layered (n-tier) architecture

An N-tier architecture divides an application into logical layers and physical tiers.

Layers are a way to separate responsibilities and manage dependencies. Each layer has a specific responsibility. A higher layer can use services in a lower layer, but not the other way around : Unidirectional communication.

Tiers are physically separated, running on separate machines. A tier can call to another tier directly, or use asynchronous messaging (message queue). Although each layer might be hosted in its own tier, that’s not required. Several layers might be hosted on the same tier. Physically separating the tiers improves scalability and resiliency, but also adds latency from the additional network communication.

A traditional three-tier application has a presentation tier, a middle tier, and a database tier. The middle tier is optional. More complex applications can have more than three tiers. The diagram above shows an application with two middle tiers, encapsulating different areas of functionality.

An N-tier application can have a closed layer architecture or an open layer architecture:

  • In a closed layer architecture, a layer can only call the next layer immediately down.
  • In an open layer architecture, a layer can call any of the layers below it.

A closed layer architecture limits the dependencies between layers. However, it might create unnecessary network traffic, if one layer simply passes requests along to the next layer.

Its main benefits are:

  • It’s quicker to develop in part because the concept of Model-View-Controller is so well known among developers.
  • Its implementation is easier.

Microservices architecture

Microservices Architecture

Microservices are both an architecture and an approach to writing software. With microservices, applications are broken down into their smallest components, independent from each other. Instead of a traditional, monolithic, approach to apps, where everything is built into a single piece, microservices are all separated and work together to accomplish the same tasks.

One of the main characteristics is the way the architectural style componentizes a complex application. The software is broken down into multiple components that are built as independently replaceable and upgradeable services. These services can be defined as processes that often communicate over a network using protocols that are technology-agnostic. Microservices are also built to suit business capabilities. And since they are decentralized and small in size, they offer a lot of flexibility when it comes to programming languages, hardware, and software environment.

It is a good choice when the application that we intend to build is pretty large. Its main benefits are:

  • Accessibility & Separation & Maintenance: Since a Microservice application is deployed separately and communicate via API requests, code becomes more accessible for developers, and maintenance is easier.
  • Error management: If a microservices architecture is implemented correctly, finding and isolating bugs becomes much easier. Whenever an error occurs, developers know exactly where to look, which saves valuable time and effort. And fixing only one independently run service means that other code won’t be affected and there is no need to deploy the whole application.
  • Scalability: One of the main benefits that microservices have to offer is their ability to be scaled horizontally. This means that any deployed service can be duplicated in order to avoid bottlenecks due to slow execution. Another option to increase performance is to run the service on more powerful hardware or multiple machines that process data in parallel.
  • Reusability: The microservices become reusable. The fact that they are independent components, makes them reusable in other projects.
  • Ease of understanding: With added simplicity, developers can better understand the functionality of a service.
  • Smaller and faster deployments: Smaller codebases and scope = quicker deployments, which also allow you to start to explore the benefits of Continuous Deployment.

Monolithic Architecture

Monolithic Architecture

Monolith means composed all in one piece. The Monolithic application describes a single-tiered software application in which different components combined into a single program from a single platform.

Monolithic is an all-in-one architecture, wherein all aspects of the software operate as a single unit. In the microservices model, components are modular, functioning independently, and coupled together as needed for optimal functionality.

When choosing between monolithic architecture and microservices, businesses evaluate factors such as rapid testing, debugging, and scalability.

Its main benefits are:

  • Easier and Faster Development: The biggest advantage is considered to be the development speed and the simplicity and straightforwardness of creating an application based on one code. There is a wide range of available tools, while it is also familiar to every development team-building concept.
  • Easier Deployment: Monolith applications are considered to be simple to deploy, as it is only necessary to handle deployment once — one executable file or directory.
  • Easier Testing and Error Tracing: With fewer variables, the risk for something to go wrong is much lower, while it is also easier to spot errors when all transactions are logged into one place.
  • Trustworthiness: As monolithic architecture is a tried and tested standard method, it is also considered to be more trustworthy than anything newer and, therefore, more untested.

Conclusion

This article covered the most known types of software architecture patterns: Monolithic architecture, Layered (n-tier) architecture, Microservices architecture.

There are many other architecture patterns that may be more fit to be used in each project. It depends of the hardware you want to use, the size of your project, and to the specific use case you’re intending to implement.

Finally, a well architected system results in excellent performance and
scalability, and a poorly architected system can lead to a poorly performing system.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store