Stan’s Robot Shop – a Sample Microservice Application

February 27, 2018

Instana is an active supporter of Open Source, we are members and contributors to a number of projects including: Open Tracing, Cloud Native Computing Foundation and Byte Buddy. Additionally the language sensors that the Instana agent uses are all Open Source on Github. Continuing with our commitment to Open Source we have just released Stan’s Robot Shop, also on Github.

This is a simple example microservices application for use as a sandbox to play with orchestration and/or monitoring/observability. As the name implies it is a simple ecommerce storefront featuring some of Stan’s friends, it includes: a product catalogue, user repository, shopping cart and order pipeline. These technologies have been used in creating the application:

  • AngularJS (1.x)
  • Nginx
  • NodeJS (Express)
  • Java (Spark Java)
  • Python (Flask)
  • Golang
  • MongoDB
  • RabbitMQ
  • Redis
  • MySQL

The key design consideration was to be small enough to run on a developer’s laptop but still have enough complexity to be interesting and not just a “Hello World” example. Just 2GB of memory is required to run this using docker-compose or minikube/minishift. Of course you can also deploy it to a cloud service that supports containers such as: Google Compute, AWS ECS/EKS and OpenShift. Future articles will cover these deployment scenarios in more detail.

Architecture

Discovered stack

The web page is a Single Page Application written using AngularJS (1.x), its resources are served by Nginx which also acts as a reverse proxy for the backend microservices. Those microservices are written in different languages using various frameworks, providing a wide range of example scenarios. MongoDB is used as the data store for the product catalogue and the registered users. MySQL is used for the look up of the shipping information. Redis is used to hold the active shopping carts. The order pipeline is processed via RabbitMQ.

Discovered services

The code already has any required Instana components installed, making it very easy to start monitoring the application with Instana, you just have to install the agent on the platform. Instana End User Monitoring is also preconfigured, you just need to add your unique key to the environment of the Nginx container.

Installation

For more detailed instructions see the README in the Git repository. You will need to have Docker installed. First of all clone the Git repository.

$ git clone https://github.com/instana/robot-shop

Now change directory to the one just created by the clone. If you want to build from the source:

$ docker-compose build

The latest images are available ready built on Docker Hub so you could just run the application locally and pull the images:

$ docker-compose up

The application will take a little while to download the images and start all the services. Once it is running you can access the web application on http://localhost:8080/

shop front

There is an existing registered user with the credentials “user/password”, you can register additional ones, the shop also supports anonymous shopping; order history is not kept for anonymous users.

Monitoring with Instana

To see the application discovered and monitored with Instana, you just have to install the agent. At the moment the agent is not supported on Mac if you are running the application locally via docker-compose. Future articles will cover deployment to other environments such as Kubernetes, OpenShift, Mesosphere, etc. From the Instana dashboard select Management Portal from the drop down menu at the top right.

menu

From the Management Portal select Install Agent, then copy and paste the Docker command line from the right of the screen. It will be already filled in with all the correct details, an example is below.

docker run \
--detach \
--name instana-agent \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /dev:/dev \
--volume /sys:/sys \
--volume /var/log:/var/log \
--privileged \
--net=host \
--pid=host \
--ipc=host \
--env="INSTANA_AGENT_KEY=<your key here>" \
--env="INSTANA_AGENT_ENDPOINT=<geo end point>" \
--env="INSTANA_AGENT_ENDPOINT_PORT=443" \
--env="INSTANA_AGENT_ZONE=Robot-Shop" \
instana/agent

Tip: Add the environment variable INSTANA_AGENT_ZONE to have the discovered infrastructure show up in the dashboard in its own group.

End User Monitoring

The required Javascript fragment will be automatically added to the page if you supply an EUM key for the web container. In the Instana dashboard select Websites from the main top navigation, then Add Website from the top right. This will show you the Javascript fragment with your key included. Copy the key and paste it into the docker-compose.yaml file, you will see there is already a placeholder there for it. Restart the application.

Load Generation

Load generation for the application is not started automatically, by navigating around the shop with your browser you can generate load and see how quickly those clicks are captured and become available in the Instana dashboard. There is not any load generation facility for the web application but there is included a load generation utility for the microservices. Under the load-gen directory edit the load-gen.sh script and change the value of HOST to point to where Stan’s Robot Shop is running.

Have Some Fun

What are you waiting for? Go and have fun with Stan’s Robot Shop and keep checking back here for new articles and tutorials all about microservices featuring Stan’s retail empire.

Play with Instana’s APM Observability Sandbox

Developer, Product
The most complex tests and the most challenging methodologies are often most closely aligned with actual production environments. Given this, how can organizations achieve the best results from testing in pre-production? The...
|
Thought Leadership
Today most applications are built using microservices. This is because microservices enable rapid scalability, agility and delivery of large complex applications.  Organizations are often fighting a losing battle if real-time data observability...
|
Announcement, Developer
We are excited to announce that Lightrun had partnered with Instana to enrich existing telemetry with real-time, code-level observability data and provide full-cycle Observability. Understanding everything that happens inside a production environment...
|

Start your FREE TRIAL today!

Instana, an IBM company, provides an Enterprise Observability Platform with automated application monitoring capabilities to businesses operating complex, modern, cloud-native applications no matter where they reside – on-premises or in public and private clouds, including mobile devices or IBM Z.

Control hybrid modern applications with Instana’s AI-powered discovery of deep contextual dependencies inside hybrid applications. Instana also gives visibility into development pipelines to help enable closed-loop DevOps automation.

This provides actionable feedback needed for clients as they to optimize application performance, enable innovation and mitigate risk, helping Dev+Ops add value and efficiency to software delivery pipelines while meeting their service and business level objectives.

For further information, please visit instana.com.