Skip to content

This repository aims to create a cloud-native application that implements 2 different distributed tracing tools: Elastic APM and Zipkin, and to compare their performance and features

Notifications You must be signed in to change notification settings

ilyas0v/nodejs-k8s-distributed-tracing

Repository files navigation

Sample Node.js Microservices Application with Elastic APM and Zipkin integrated

This repository aims to create a cloud-native application that implements 2 different distributed tracing tools: Elastic APM and Zipkin, and to compare their performance and features.

Here is the basic architecture of the setup:

image

Project Structure

  • src/index.ts: This is the entry point of the application. It starts the corresponding service specified via the SERVICE_TYPE environment variable.
  • k8s: This folder contains the configuration files for the deployments, services, configuration, and ingress of the application.
  • elastic: This folder contains the deployment and services for APM Server, Elasticsearch, and Kibana.
  • zipkin.yaml: This file contains the deployment and service configuration for the Zipkin server.

Build and Deployment

  • build.bat: This script builds the application as a Docker image and pushes it to the Docker Hub registry.

Steps to run on kubernetes

  • build the application as docker image. Update the deployment files accordingly in ./k8s/service-x.yaml
  • then apply the deployments and services:
kubectl apply -f ./k8s/service-a.yaml
kubectl apply -f ./k8s/service-b.yaml
kubectl apply -f ./k8s/service-c.yaml
  • set the config variables: kubectl apply -f ./k8s/config.yaml

  • configure the ingress to combine services in a load balancer:

kubectl apply -f ./k8s/ingress.yaml

  • configure the Elastic APM and related services:
kubectl apply -f ./elastic/elastic.yaml
kubectl apply -f ./elastic/apm-server.yaml
kubectl apply -f ./elastic/kibana.yaml
  • configure the Zipkin server
kubectl apply -f ./zipkin/zipkin.yaml
After doing these, the application services, and elastic services will be up and running. Check them by their ports accordingly. The Elastic APM will be accessible via Kibana dashboard.

Testing routes

curl ${APP_HOST}/service-a/
curl ${APP_HOST}/service-a/routeWithLongOperation
curl ${APP_HOST}/service-a/routeWithError

Check the Kibana dashboard -> APM -> Services and Traces

Page Image
Services Overview services overview
Traces Overview tracing overview
Timeline View timeline normal

Check Zipkin dashboard -> Traces, Dependencies, Timeline

Page Image
Dependencies Overview image
Traces Overview find traces
Timeline View timeline normal

Simple benchmarking to test the impact of each tool on application latency

The Autocannon tool was used to run load testing for 30 seconds with 10 connections. Here are some insights:

Metric Without tools With Zipkin With Elastic APM
Average latency 204.38 ms 242.56 ms 277.77 ms
Requests per sec 84.7 54.6 43.3
Bytes/sec 19.3 kb/sec 12.4 kb/sec 9.87 kb/sec

About

This repository aims to create a cloud-native application that implements 2 different distributed tracing tools: Elastic APM and Zipkin, and to compare their performance and features

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published