10 Challenges and Solutions for Microservices — Tips and Tricks

DZone 's Guide to

10 Challenges and Solutions for Microservices — Tips and Tricks

Read up on the ten major challenges with microservices architecture that software companies and the open source community are aiming to solve.

· Microservices Zone ·
Free Resource

I am a cloud API developer and architect and currently working on Google's GCP based microservices for a large retail client of USA.

Transitioning/implementing to microservices creates significant challenges for organizations. I have identified these challenges and solution based on my exposure to microservices in production. 

I am writing this in June 2018. At this time, microservices architecture has not matured enough to completely address all the existing challenges, however, open source communities and IT product companies are trying to address all these open issues. All new research on these topics is based on finding solutions to the new challenges.

These are the ten major challenges of microservices architecture and proposed solutions:

1. Data Synchronization (Consistency) — We have event sourcing architecture to address this issue using the async messaging platform. The SAGA design pattern can address this challenge.

2. Security — An API Gateway can solve these challenges. Kong is very popular and is open-source, and is being used by many companies in production. Custom solutions can also be developed for API security using JWT token, Spring Security, and Netflix Zuul/ Zuul2. There are enterprise solutions available, too, like Apigee and Okta (2-step authentication). Openshift is used for public cloud security for its top features, like Red Hat Linux Kernel-based security and namespace-based app-to-app security.

3.  Services Communication — It's complex to communicate between microservices. There are the different way to communicate - Point to point using API Gateway and pub/sub event driven model.

4. Discovery — This will be addressed by API discovery tools like Kubernetes orchestration, Pivotal Application Services (PAS), container services (PKS) and OpenShift. It can also be done using Netflix Eureka at the code level. However, doing it in with the orchestration layer will be better and can be managed by these tools rather doing and maintaining it through code and configuration.

5. Data Staleness — The database should be always updated to give recent data. The API will fetch data from the recent and updated database. A timestamp entry can also be added with each record in the database to check and verify the recent data. Caching can be used and customized with an acceptable eviction policy based on business requirements.

6. Distributed Logging, Cyclic Dependencies of Services and Debugging — There are multiple solutions for this. Externalized logging can be used by pushing log messages to an async messaging platform like Kafka, Google PubSub, Built-in Kibana dashboard of OpenShift PAAS solution, which reads console logs from container and aggregate in its ElasticSearch persistence on the server, It's persisted even when POD is crashed and restarted, etc.

It's difficult to identify issues between microservices when services are dependent on each other and they have a cyclic dependency. Correlation ID can be provided by the client in the header to REST APIs to track the relevant logs across all the pods/Docker containers.

7. Testing — This issue can be addressed with unit testing by mocking REST APIs or integrated/dependent APIs which are not available for testing using WireMock, BDD, Cucumber, integration testing, performance testing using JMeter, and any good profiling tool like Jprofiler, DynaTrace, YourToolKit, VisualVM, etc.

8. Monitoring & Performance — Monitoring can be done using open-source tools like Prometheus in combination with Grafana by creating gauge and matrices, GCP StackDriver, Kubernetes/OpensShift, Influx DB, combined with Grafana, Dynatrace, Amazon CloudWatch, VisualVM, JProfiler, YourToolKit, Graphite etc.

Tracing can be done by the latest Open tracing project or Uber's open source Jaeger. It will trace all microservices communication and show request/response, errors on its dashboard.

9. DevOps Support — Microservices deployment and support-related challenges can be addressed using state-of-the-art DevOps tools like GCP, Kubernetes, OpenShift and PCF with Jenkins.

10. Fault Tolerance — Netflix Hystrix can be used to break the circuit if there is no response from the API for the given SLA/ETA and provide a mechanism to re-try and graceful shutdown services without any data loss. 

microservices ,software architecture ,software development ,software testing ,monitoring

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}