Microservices


Microservice architecture is a growing approach to deliver robust solutions, with many companies moving to a cloud based environment with a focus on team based DevOps, Microservices are a great way to handle this.

What are Microservices?

Microservices are a specialised implementation following the approach of service-oriented architectures (SOA), which are used to build robust/flexible and independently deployable software solutions.

Microservices can belong in a Microservice architecture (MSA), which is where services belong in a network that communicate and orchestrate with each other to perform complex flows.

Microservices do not need to be tied down to a single technology stack, but it is encouraged to utilise the technology stack that best suits the purpose.

Microservice VS Mono

What do Microservices offer?

Microservices offer many advantages such as:

  • Multiple or single teams can easily can easily work on the overall solution (complex flow across multiple services)
  • Easier for team to understand the service (purpose of each service is clear and concise)
  • Easier to detect where faults occur (fault isolation)
  • Simplistic testing (Unit, Functional, Interface)
  • Selection of an technology stack fit for purpose (not tied to a single technology with monolithic solutions)
  • Cloud hosting support

There are a few key details you need to be aware of though such as:

  • Can have complicated deployments (multiple deployment for a single enhancement)
  • Can have complicated transaction management (multiple databases, rollback strategies etc)
  • Can have complicated testing (E2E)

Why should I consider Microservices?

Beside the advantages / disadvantages mentioned above.

Given the increasing push for cloud based solution hosting such as AWS, Azure… Microservices offer an easy and great approach to utilise this no matter the size of your project or organisation. If you want to host your Microservices AWS offers quite a cost effective approach through EC2 or if you want to go serviceless then you can look at utilising AWS Lambdas.

But just to note, you can also have a network of Microservices without have a cloud based solution, simply by deploying to an environment that can run your Microservice/s… the power is in your hands.

What do you mean state/data management?

It is worth noting that services if requiring state/data should have their own database or state management that is not tied to other services in the network, that being said though, services following this approach can then have added complexity especially around transaction management such as failures (rollbacks) in the network and data management.

Pattern: Database Per Service

As mention above this can add complexity and difficulty when managing state/data across your network of Microservices, to help mitigate problems there are is a pattern that can be used Event driven architecture – Event Driven Architecture

Event driven architecture will solve the issues presented with having a database per service, but setting this up this pattern can be a challenging process but well worth the effort.

Helpful Tips?

When dealing with complex flows, it is important that you have a unique id that will pass through all the flow, this means when when debugging or trawling through logs files you can see the flow from start to end and better manage transaction interactions though the varies services your flow passes through.

Example

You can check out the project from the following location below:

Project URL: https://github.com/Rob-Leggett/gradle_springboot_microservice
What you can learn:

  • Gradle
  • Springboot
  • Stateless Microservice
  • Multipart
  • Unit Tests
  • Functional Tests
  • Swagger 2
  • Code Coverage
  • Checkstyle
  • Spock
  • Java 8
  • Groovy
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s