How-tos

Microservices on Bluemix: A multi-compute approach using Cloud Foundry and OpenWhisk

Share this post:

Microservice Architecture Compute Choices

There are many advantages to a microservice architecture, and just as many advantages for why Bluemix is a platform ideally suited to that application construction technique.

One of the benefits of microservices is that each of the applications that compose your solution can be built using whatever language or framework makes sense for that particular application. Each application has different needs based on its function: UI, API, worker, etc. Because every language has its own advantages and disadvantages, this architecture makes sense.

What if each of the microservices could not only be built with a different language but also using a different Bluemix compute platform? That would allow the most flexible implementation, and provide a range of benefits that you might not have initially realized.

Let’s check it out.

Bluemix and Cloud Foundry

Cloud Foundry applications are a great choice when you want to quickly develop a 12-factor application (node, java, php, python..), with the ability to bring in frameworks (Express, MEAN, Loopback, Java EE, Spring, Flask), connect to databases with an object modeler (mongoose) and manage authentications and sessions (passport), etc. The platform gives you the ability to deploy these applications and scale easily while still giving you the control over your entire application.

Bluemix OpenWhisk

openwhisk

An event-driven computing platform such as Bluemix OpenWhisk allows you to write code snippets or functions in your favorite language. Called actions, these are suitable for when you want to run stateless logic in response to some event/trigger. You can still connect to databases and APIs, but each action usually completes a small stateless task and returns quickly.

Imagine if you split apart all the process/memory/network intensive functions and put them on their own — these would be your actions. Deploying them to OpenWhisk would allow them to scale on demand, and you would only pay for actual usage. No application servers to manage!

openwhisk-serverless-architecture-28-638

Logistics Wizard: Full microservices demo application

Logistics Wizard is an enterprise-grade sample application which leverages both of these compute options. Written as a full application by the Developer Super Hero Squad, it is a smart supply chain management solution that aims to simulate an environment running an ERP system. It augments this ERP system with applications to improve the visibility and agility of supply chain managers.

LogisticsWizardDashboard2

We used an architecture that is comprised of a set of loosely-coupled, distributed services that take an existing ERP system and extend its functionality by leveraging various cloud services. In essence, a full microservices approach.

Logistics Wizard Components

Logistics Wizard consists of four main parts:

  • ERP (Cloud Foundry – Node.js w/ Loopback) — defines the API used by the Logistics Wizard to access data from an ERP system. The simulator is a Node.js application connected to a PostgreSQL database. Through its API, it manages users (supply chain managers and retail store managers), distribution centers, retail stores, and shipments.
  • WEBUI (Cloud Foundry – React) — the main UI which provides a dashboard for supply chain managers and retail managers to see all the shipments, retail locations and distribution centers, as well as weather and its effect on the supply chain.
  • Recommendations (OpenWhisk Actions – JavaScript) — makes shipment recommendations based on weather conditions. It’s a set of OpenWhisk actions to retrieve current weather conditions and given a weather event to generate new shipment recommendations.
  • Controller (Cloud Foundry – Python Flask) — acts as the main controller for interaction between the services. It receives requests from the user interface and routes them to the ERP or the weather recommendation module.

LW_Architecture_Diagram

Logistics Wizard Cloud Foundry ApplicationsScreen Shot 2017-02-02 at 10.33.09 PM

You’ll notice that we deploy “dev” and “prod” versions of each of the three Cloud Foundry applications.

Logistics Wizard OpenWhisk actions

Screen Shot 2017-02-02 at 10.31.16 PM

Check out Logistics Wizard’s main github repository for more details about all the components that make up this solution and how they all come together. We use continuous integration to automate the entire lifecycle for all the microservices independently.

Learn more about the Logistics Wizard on Bluemix by viewing the video below.

Create your own microservices

Interested? Read these posts to discover everything we did to build the Logistics Wizard UI, API, testing and do continuous delivery. We very much encourage you to crib our code and extend it or use it as a base for your own applications.

Just contact us someday and tell us what you’re doing. Happy Coding!

IBM Cloud Technical Offering Manager

More How-tos stories
August 16, 2018

Call for Code is Ready to Help Save Lives When Weather Strikes

Perhaps the next great advancement of our age, a better way to protect people from destruction, is an idea you have . . . a code that can save lives. Learn more about Call for Code, a rallying cry for developers to help create the next big solution to disaster crisis.

Continue reading

July 18, 2018

Part III: Wimbledon Facebook Bot on IBM Cloud

Delivering at scale: In the final part of the series, we discuss integrations with on-site systems at the All England Club and how we used Multi-Region within IBM Cloud to ensure scale and availability.

Continue reading

July 13, 2018

Part I: Wimbledon Facebook Bot on IBM Cloud

Integration with the Facebook platform: This is the first in a series of posts that will detail how IBM iX designed, developed, and delivered the Facebook Messenger Bot available at the The Championships, Wimbledon 2018.

Continue reading