3

I'm starting out on the journey of learning/implementing microservice architecture for the first time and I have some questions related to the implications that has.

For some background, the techstack I intend on using is in a very over-arching sense is dockerized spring-boot microservices running on AWS.

So what I want to know is...

Firstly, given that each microservice is supposed to be full stack including separate databases does this mean I need 3 separate instances of whatever database I choose runnning? I'm guessing the answer is yes. So, I guess my real question is, isn't this consuming a lot more hardware resources than a monolithic application with a single database? Databases are pretty memory hungry...

Not only that but the full amount of ram required for running a single spring-boot application will be required 5 times over if I'm running 5 microservices right? It seems to me this would require far, far more ram than the monolithic application, correct?

What about if you are using Oracle as a database? What implications does it have for licencing? Wouldn't it get crazy expensive if you need a separate database for each microservice?

Are there any other licencing pitfalls to consider? Or any other pitfalls of MSA in general that one should consider/be aware of before starting out on this journey?

Edit: Also, given each microservice is full-stack, what if I want a consist looking front-end for each of them (where a microservice requires a front-end)? I haven't seen any good advice around this. Especially given (if they are so called '12 factor') the codebase is supposed to be in separate repository for each microservice. How is this best managed/achieved?

james_s_tayler
  • 1,823
  • 1
  • 15
  • 20
  • 2
    Is it your requirement that each micro-service is fullstack? That is not how I would define it, in fact, its almost the exact opposite. You are creating monolith applications running in containers. – E.J. Brennan Jan 13 '16 at 19:02

2 Answers2

5

This is a big list, but I'll give it a shot:

Databases: Yes, they should have their own database. That does not necessarily mean their own database SERVER, that is a scaling concern, but you certainly don't want to couple them together. The absolutely cleanest way is to separate them physically, but for a licensing standpoint, separate schemas that don't have permission to each other is probably sufficient.

RAM: Yes, this will definitely require more space for the program area. This is usually irrelevant, as the data for programs usually far outstrips the program/framework memory. I believe the spring boot framework needs around 18 mb to run. Unless you have a very small service, you are going to need an order of magnitude (or two) more RAM to run your service, at which point the spring framework is a rounding error. Even the JVM itself is probably overwhelming this. You can do some testing, but please don't spend any time optimizing away 2-3 mb of RAM... Optimize when you hit a gig or more.

Licensing: Other than the above comment on database instances, this is too broad to address. If you are licensing individual products/libraries, then you will have to consult your license agreement to see how it will break out. Some license by the "server", some by the "application", some by the process.

UI: I don't really understand this. Microservices are assembled into an application. That application has a UI. The services themselves don't usually have a UI. This application is usually either a separate application server, or sometimes just a HTML page with javascript to invoke the services.

Rob Conklin
  • 8,806
  • 1
  • 19
  • 23
  • Thanks for that link on the memory profile of Spring Boot. Some really good stuff in there. Very relevant info to what I want to know. – james_s_tayler Jan 14 '16 at 22:47
2

Some of the things below might be a bit of a repetion based on what you know but let's see if parts of it can be useful for you still.

The idea of microservices is to design each service around a single responsibility or quite common a single domain. This would mean that you will have different services handling Product APIs, Order APIs, Basket APIs and Customer APIs. As you already guessed, this would mean you will have all this data split between different databases and services collaborate with eachother, never access their own databases directly.

This allows you to have all the business logic contained in one place and achieve that services are:

  • Released and Deployed independently
  • Replaceable and easier upgradable
  • Scaled independently
  • Easier & faster releases
  • Easier to test

Implications

More things can go down

Implications of such approach is naturally a more complex deployment infrastructure and more things that can go wrong as services are communicating with each other typically over HTTP with REST APIs, but sometimes over pub-sub, Protocol Buffs or Thrift, or other light-weight messaging protocol. This leads to possible timeouts in communication, latency, etc.

You will have to account for "things can go down" scenario much more than in a monolith and handle it according to your requirements. There are libraries and tools that help you with, for example Spring-Cloud-Netflix project wraps in Netflix Hystrix for circuit breaker support which helps you handle timeouts with remote service communications.

Resource usage

When it comes to resource usage it depends on how you look at it. Multiple services combined will most likely use more resources than monolith, especially if you account for multiple database instances, etc. However let me give you an example when for instance deploying to AWS and using Auto-scaling support that AWS provides.

In a monolith you will scale the whole application. when the load on your application increases. This means that you will spin up more EC2 machines even if it's only a certain piece of the code that is being under pressure.

In a microservice architecture you are able to scale each service on it's own depending on usage. This can lead to a much better resource utilization and being more cost-effective at the end as each service will use only a fraction of what a monolith does.

A few words about UI

I think the UI should be treated as a separate service as well. It should only provide the UI itself but not the business logic for certain operations - it's a responsibility of each microservice. So if you have a webshop, you may end up with the following services:

  • Frontend UI
  • Purchase service
  • Basket service
  • User service
  • Product service
  • Order service
  • Shipping service
  • ... possible quite a few more.

The only logic your UI should have is how to display different type of data and then communicate with underlying services. However, UI can be combined by many different services too! As an example, Amazon has many different cervices that power each page you see and parts or the UI can be generated and shown by different UI services. It all depends on how small you want to make your services.

There is a very good book "Build Microservices" by Sam Newman that I strongly would recommend you read - it covers a lot of these things and much much more. It should also answer a lot of different questions that may arise over time the more you dig into the beautiful world of microservices.

Alexej Kubarev
  • 853
  • 8
  • 14
  • Thanks for point out latency/communication issues between services. Also, yeah I think you're right - the UI should be essentially and 'aggregator' service which provides a single interface for the user to be able to effectively talk to the other services. – james_s_tayler Jan 14 '16 at 21:50