DEV Community

Cover image for When Winston with MySQL or CloudWatch Go Wrong: Node.js
Rishi Kumar
Rishi Kumar

Posted on

3 3 4 5 4

When Winston with MySQL or CloudWatch Go Wrong: Node.js

A Fleeting Glimpse of Smooth Sailing

Sometimes, everything looks perfect on the surface. The Node.js app is snappy, logs are going exactly where you want them, and the performance metrics appear respectable—even under a healthy testing load. That was how my recent experiment began. I hooked up Winston to handle logs, fired up k6 to generate traffic, and kicked back to see if everything would hold together.


The Winston + MySQL Puzzle

Initial Performance Numbers

  • About a 5% dip in app performance under load
  • Over 350,000 requests successfully processed

Hidden Problem

  • Only ~70,000 logs made it into the MySQL database
  • The rest were backed up in Node.js streams, waiting to be inserted

Why It’s Terrifying

  • A simple crash could wipe out tens of thousands of logs still stuck in memory
  • Critical debugging info would vanish, leaving developers in the dark

What This Means in Practice

Even though things looked okay on the front end, Winston-MySQL couldn’t keep up with the log volume. Winston+MySQL, by default, was processing logs one by one through a Node.js stream. Over time, the queue just ballooned, and if anything went wrong, a huge chunk of important log data could simply be lost.


Winston + CloudWatch Chaos

Decent Early Results

  • Around a 15% performance hit during moderate loads
  • Logs arrived consistently in CloudWatch at first

The Domino Effect

  • Under heavier traffic, log processing consumed too many resources
  • The logging setup itself crashed, taking the entire node.js service down

Why It’s Risky

  • A logging tool that can destabilize the core app is a serious flag
  • Production environments need stability—tolerating a logging-induced crash is out of the question

Lessons Learned

CloudWatch felt fine at lower volumes but quickly turned into a showstopper under heavier traffic. Instead of giving us reliable insights, it caused resource contention that brought the house down.


Rethinking the Logging Approach

Both Winston-MySQL and Winston-CloudWatch have their places, but these examples highlight how important it is to choose the right logging strategy for your specific load. Your logs should be fast, reliable, and never the source of crashes or major bottlenecks.

No one wants to stay up at night worrying about incomplete logs or random crashes. Logging might not be the flashiest part of the application, but it’s one of the most critical. And when it’s done poorly, it can have a bigger impact on performance and reliability than almost anything else in your stack.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay