Microservices: Building a Distributed App with Cloud Foundry and Spring

by Volha KurylionakAugust 27, 2015
This talk by Matt Stine of Pivotal includes a live demo that shows how to assemble and manage scalable microservices systems using Spring and Cloud Foundry.
Why read this?
FOR A CIO

Adopting microservices and a PaaS usually means splitting your data, which leads to dramatic changes in how it is managed, stored, and queried. Watch this video to understand how to modularize data for microservices, how to build scale-out data platforms with Cloud Foundry, and how to implement real-time analytics using Lambda Architecture.

FOR AN ARCHITECT

Dividing a monolith application into a set of meaningful services is not easy, especially if your system is already complex. Matt Stine shares some strategies for singling out business capabilities and building a microservices system around them with Spring and CF.

How does it all come together?

In his talk delivered at SpringOne2GX 2014, Matt Stine goes over some strategies for building and managing a distributed microservices architecture. He also shares advice on how to succeed in building microservices and avoid overloading your operations team with unnecessary work. The main three take-aways are that:

  1. Business capabilities and the data model need to be separated into small meaningful units.
  2. It is better to use a Platform-as-a-Service, such as Cloud Foundry.
  3. There are many ways to query data that is spread across several locations—e.g., you can use Lambda architecture.

Microservices 2 Matt Stine

 

Splitting a monoliths into microservices

The first one might be the hardest. Dividing data that has always been stored in a single database can be a challenge. However, this step is critical to overall success. Matt Stine offers a plain strategy that can be employed by many businesses. He suggests using contexts to single out business capabilities and underline the data models associated with them. Once you know what activities and data belong to what context, you can build microservices around them. Then you can use a different data store with each microservice to get the features you need in terms of writing/reading speed, transactions, etc.

 

Using a PaaS to manage microservices

The second point is running and managing all the services. If your system is large, this may be a potential nightmare for your operations team. In addition, how do the people working with your system know how to use each and every datastore type you employ?

Fortunately, there is a kill-two-birds-with-one-stone way to solve both of these issues—a platform, such as Cloud Foundry. A PaaS not only simplifies deployment, monitoring, and management of services, but also creates a level of abstraction between your operators/developers and the underlying technology stack, automating the maintenance and mangement tasks associatied with it. E.g., you can provision a database for your service in minutes.

There are quite some Cloud Foundry-based PaaSes available today. These include public cloud deployments, such as Pivotal Web Services and IBM Bluemix, complete with a selection of pre-installed managed services. On the other side of the spectrum are some options that can be deployed to a private data center—e.g., Pivotal CF and the open source version of Cloud Foundry. Note that if you choose a private deployment, you may need to take care of service provisioning on your own.

 

Getting business questions answered

Finally, a lot of those who are considering microservices wonder: “How do I get answers to my business questions if all the data and business logic are separated into dozens of small pieces?” or “How do I make queries that span several data stores associated with different microservices?” According to Matt Stine, there are many ways to accomplish this. For instance, you can use Lambda architecture. This approach makes it possible to process data both in real time and in batches, so you can even employ Hadoop and work with big data.

Matt illustrates his points with a live demo of a distributed application for a movie rental service, based on SpringBox Microservices running on Pivotal Cloud Foundry. What’s cool about the app is that it was created in as little as 48 hours. This is a great demonstration of how automation tools, such as CF and the Spring framework, help to save time when building and managing software.

 

Altoros Take

As noted in Matt Stines talk, along with advantages, such as scalability and tighter release cycles, microservices also have a number of downsides, including implicit interfaces, significant operational overhead due to redundancy, and operational complexity. As a result, managing microservices-based systems can become a nightmare, unless you use a PaaS—e.g., Cloud Foundry.

Cloud Foundry takes away a lot of the headache associated with running distributed systems. Here is how it helps to solve the most common issues:

  • Implicit interfaces. In Cloud Foundry, microservices are deployed as applications and communicate through CF Router. When a service is published, it gets a unique URL in the Cloud Foundry domain. URLs and application routes are created automatically when an application is deployed. Router handles communication between applications in CF in the same way as if they were accessed from outside CF. However, the traffic does not leave the private network. In general, communication between apps in CF is not standardized—there are many different options with various trade-offs.

  • Significant operational overhead. With Cloud Foundry, application development is simplified considerably. It is just a part of application release life cycle. The PaaS handles development and staging, as well as production applications. There is no need to separate them into different IaaS deployments.

  • Operational complexity. Cloud Foundry automates scaling and deployment of applications, as well as health monitoring and load balancing. You will not have to create additional scripts to automate monitoring and scaling in your IaaS. In a PaaS, Router serves as a load balancer, so you do not have to add it as a separate component (like when you are using an IaaS).

  • Lack of DevOps skills. The high level of automation implemented in Cloud Foundry enables developers to concentrate on building and releasing applications. The development, testing, and production release processes are identical in terms of how you deploy. Additionally, the PaaS hides the complexity of the underlying IaaS solution.

You can find more details on how Cloud Foundry helps to address the challenges brought by microservices in our guide.

 

Want details? Watch the video!

Table of contents
  1. Why microservices? (1:05)
  2. How to modularize your data (2:33)
  3. Getting business questions answered (16:41)
  4. What is Lambda architecture? (17:32)
  5. Managing microservices with a PaaS (23:17)
  6. Sample microservices architecture (28:33)
  7. Lambda architecture with Spring XD (31:22)
  8. A sample app deployed to Pivotal Web Services (33:52)
  9. A live demo of the sample app (35:15)
  10. Gauging movie preferences (49:20)
  11. The master dataset (56:40)
  12. How to create reporting views (1:00:15)
  13. Event sourcing and microservices (1:07:44)
  14. Is the master dataset a single point of failure (1:09:06)
  15. Why is it better to have raw data in your master dataset? (1:14:03)
  16. Do you need to calculate batch view in the serving layer all the time? (1:16:23)
  17. Is Spring XD the new Greenplum? (1:18:09)

 

About the speaker

Matt Stine is Senior Product Manager, Spring Cloud Services for Pivotal CF. His extensive experience embraces healthcare, biomedical research, e-commerce, and retail store domains. He is also a technical editor of the NFJS magazine and a recognized conference speaker who delivers sessions on project automation, continuous delivery, Lean and Agile software development, modern Web app testing, etc.

 


Related slides

 

Related video