Пропустить навигацию
Node.js doesn't have a predictive way to manage traffic spikes, so over-provisioning for peak loads…
0:00 / 5:35

Node.js doesn't have a predictive way to manage traffic spikes, so over-provisioning for peak loads…

Matteo Collina

@matteocollina56 тыс. подписчиков

Открыть в X
165 отметок «Нравится»СкачатьОригинальный пост

31 763 просмотра

Node.js doesn't have a predictive way to manage traffic spikes, so over-provisioning for peak loads isn't optimized for the stable periods that follow. We've all faced this issue. This is why Platformatic is simplifying multithreading in our Node.js app server. Let’s see why🧵

13 комментариев

Комментарии из оригинального поста в X (Twitter)

  • Фото профиля Matteo Collina

    @matteocollina

    Node.js applications are usually deployed as single-threaded: ↳Each instance operates as a single process. ↳Organizations overprovision to handle traffic spikes. ↳This leads to wasted resources and increased costs.

    1 отметка «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    ↳Additionally, heavy computations can block the event loop, causing performance and user experience issues.

    2 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    What’s clear is that we need to rethink our approach to infrastructure. This is why @platformatic’s Watt app server now supports service replication. By starting multiple workers, you can now fully utilize all the CPU cores available on your server, providing the best possible user experience.

    5 отметок «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    Most importantly, this is all done without requiring any code changes on your part.

    2 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    What does this mean for your application’s performance? Hint: it’s great news.

    2 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    As an example, let’s analyze a basic Next.js application running within Watt. *This test was conducted on an Apple MacBook Pro with an M1 Max chip.

    1 отметка «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    When subjected to 100 connections using autocannon over a span of 10 seconds, the system produced the following performance metrics:

    2 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    Upon examining the top data, we found that only 3 out of the 10 available cores were actually utilized. We then repeated the test, increasing the number of `workers` to 2, and here are the results:

    2 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    This shows an impressive performance boost—almost a 100% improvement—simply by changing one line in a JSON file.

    1 отметка «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    Finally, we repeated the test, this time using 3 workers for the service.

    3 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    What were the results? • 1 Worker: P99 latency 309 ms; 5k requests in 10s • 2 Workers: P99 latency 197 ms; 10k requests in 10s • 3 Workers: P99 latency 161 ms; 11k requests in 10s

    3 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    Upon reviewing the top data once more, we found that all 10 CPU cores of the machine were fully utilized.

    3 отметки «Нравится»

  • Фото профиля Matteo Collina

    @matteocollina

    With the introduction of multiple workers, we're transforming how Node.js services scale and perform. I can’t wait to see you all try it out!

    10 отметок «Нравится»