question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multi-threaded setup

See original GitHub issue

I’ve been running the internal osrm-backend C++ API in the past, and recently came across that it’s not supposed to be run in production. On my way to migrate to node-osrm, I came across an issue: I can’t get a setup to work that uses more than ~1.5 CPU threads.

As nodejs is single-threaded, I was using the nodejs internal cluster module, and I also tried load-balancing requests using haproxy to two different instances of node-osrm on the same machine. I’m using var osrm = new OSRM(); to access the map data via SHM (loaded via osrm-datastore).

While both approaches succeed in spawning multiple instances of osrm-node and all instances are retrieving and processing requests, the overall CPU load on the server is still roughly the same as with the single node-osrm setup. I therefore assume that there’s a lock somewhere in the osrm-node -> libosrm techstack preventing parallel use.

How do you guys run node-osrm in production? Are you just relying on a single core, or is there something I missed?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:32 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
TheMarexcommented, May 18, 2016

@chr4 actually we tried to reproduce this and saw a similar behavior. @daniel-j-h is working on a fix that should utilize the all the cores using nan::AsyncWorker instead of hooking into the libuv thread pool directly.

0reactions
f3d0rcommented, Sep 3, 2018

Thanks for the advice! Is there anything I can do to allow SSH-type behavior with the node.js wrapper for OSRM? Also (this might be better in a separate issue), but is it possible to use MLD-compiled .osrm files for node-osrm?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is Multithreading: A Guide to Multithreaded Applications
Multithreading is a model of program execution that allows for multiple threads to be created within a process, executing independently but ...
Read more >
Multithreading in Java - Everything You MUST Know
Multithreading is a programming concept in which the application can create a small unit of tasks to execute in parallel.
Read more >
Multithreading (computer architecture) - Wikipedia
In computer architecture, multithreading is the ability of a central processing unit (CPU) to provide multiple threads of execution concurrently, ...
Read more >
Multithreaded Servers in Java - GeeksforGeeks
Server file has two classes, Server(creates a server) and ClientHandler(handles clients using multithreading). MultiThreaded Server Programming.
Read more >
Python - Multithreaded Programming - Tutorialspoint
Multiple threads within a process share the same data space with the main thread and can therefore share information or communicate with each...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found