DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Best Tools for Debugging Distributed Applications

Best Tools for Debugging Distributed Applications

Take a look at some of the best tools and methods for getting your distributed applications debugged and back in business.

Chris Ward user avatar by
Chris Ward
CORE ·
Oct. 18, 18 · Presentation
Like (1)
Save
Tweet
Share
6.44K Views

Join the DZone community and get the full member experience.

Join For Free

Distributed systems such as Kubernetes bring many advantages to the modern application stack, but also many complications and moving parts. When something does go wrong, or not according to plan, tracking down the cause is trickier than with "traditional" applications. There can be several factors and complications introduced.

System(s) Inconsistency

While Kubernetes pods and Docker containers help you maintain some consistency, they are often running on a variety of different underlying machines, all bringing nuances in terms of components, operating systems, and minor version changes.

The nature of a distributed system often brings a mixture of programming languages, storage standards and protocols communicating between them. Most modern tools use standards such as JSON for data exchange, RPC, RESTful interfaces or message buses, and while these solve standards issues, they introduce one more component to add to your debugging trail.

Who Gets There First

Race conditions or inconsistent concurrency occurs when events happen in a system, but not in the order you expect. It's a common problem in any architecture, but compounded with distributed systems with multiple components, instances, network speeds and competition for system resources.

Maintaining Truth

Closely related to the above is maintaining a source of truth for data values in the application. If multiple applications can write the value of an event, which do we consider the right answer? What if elements of your cluster experience downtime, and data loss in transmission? Again, what do you consider the last consistent state and how do you restore it? There are container design patterns that help make these processes more manageable, but there will still be times when you need to dig deeper.

Solutions

Debug Containers

Debugging what is going on inside containers is trickier than when you run code on your local machine. While commands like attach, exec, logs, stats and top (and their Kubernetes equivalents) help, they only take you so far, especially as an application scales to use multiple containers.

Common container design patterns encourage you to create the smallest containers possible, with little headroom for bundling debug tools that you may or may not need. Enter the concept of "sidecar containers" that provide services to other containers when you need them, without muddying your core containers. In these containers, you can package tools such as busybox, or some of the other tools we cover in the rest of this post.

Log All the Things

Logs are always your friend when things go wrong, and with Kubernetes, your cluster, your containers, and your applications all produce logs. The issue isn't a lack of information, but parsing it all into something useful. None of these log sources provide any method of reading or storing output beyond writing to standard output and error streams. For maximum usefulness, you need a separate backend, ironically adding an extra component that might require debugging.

You can log straight from the application level into a logging backend that suits the language or application.

You can log at a cluster node level, again to a backend of your choice and use a DaemonSet to duplicate the service across your cluster.

At a cluster level, and separating concerns, you can use a sidecar container as mentioned above that periodically collects logs from application containers and passes them to a logging backend.

For the two latter options, Kubernetes supports Fluentd, an open source data collector that many backends support.

For further details read the Kubernetes logging guide.

There are also commercial logging tools available, such as DataDog, New Relic and Lightstep that handle logging all levels of the application stack for you in one interface.

Tracing

Taking logging a step further, tracing allows you to follow the execution of an application component, helping you drill down into what went wrong and where. As distributed applications have grown in popularity, so have distributed tracing tools, providing a valuable overview to help you follow execution of the workload across a cluster.

There are popular tracing tools such as OpenTracing, Zipkin, Pivot Tracing and Jaeger, but the considerations to your project are similar to logging. You need to architect your application, nodes, and clusters to fit a tracing library, meaning it offers you unparalleled ability to find a problem, but only after you invest a significant amount of time.

Event Sourcing

An alternative idea to consider for helping with maintaining state and concurrency, or at least helping understand how it got to where it is, is event sourcing. Instead of maintaining state in your application, you instead maintain a continually updating log of events, and what triggered them in an external store. Then if an application state is ever in doubt, and you need to debug what happened, you replay the events leading up to it to ascertain at what state the application should be.

Hosting Provider Tools

If you are hosting your Kubernetes cluster with Google Cloud or AWS, then you have tools that come with those hosting environments. This doesn't mean you have to use them, and you can install any of the other options mentioned here.

Google built Stackdriver from the ground up for cloud-native applications, and appealingly doesn't try to lock you into Google's cloud or ecosystem. It runs in most environments, and integrates with a growing number of third-party tools.

If you are already well invested in the AWS ecosystem, then X-Ray will suit you. However, it only runs on AWS, so can't be used in hybrid cloud architectures, and only works with Java, Node.js, and .NET applications running on specific AWS services.

Final Thoughts

While the initial planning and architecture behind debugging a distributed application can take time, there's a growing number of tools available to help you pin down the problem and find solutions. In this post, we looked at the different approaches available. Some are tightly coupled to your infrastructure tool or host, and others sit more independently, allowing you to switch techniques more easily. We'd love to hear what options you tried and anything you learned during the process.

application Docker (software) Kubernetes

Published at DZone with permission of Chris Ward, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Differences Between Site Reliability Engineer vs. Software Engineer vs. Cloud Engineer vs. DevOps Engineer
  • A Brief Overview of the Spring Cloud Framework
  • ChatGPT Prompts for Agile Practitioners
  • Top 5 Node.js REST API Frameworks

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: