Skip to content

running ngrestserver in production with requests proxied via nginx #99

@raadiy

Description

@raadiy

Hello ngrest maintainers / community,

I am evaluating ngrestserver as a standalone REST server in a production environment and would like to clearly understand its internal concurrency model.

Background / context
We are porting a large legacy C++ codebase (originally written for CORBA-style services) to REST using ngrest.

The codebase contains:

  • Global variables (including Pro*C / Oracle globals like SQLCA, SQLDA, ORACA)
  • Global objects instantiated at load time
  • Some legacy thread-unsafe constructs (e.g., non-reentrant functions)

Historically, this code ran safely in a multi-process, single-request-per-process model (multiple service instances, no shared memory).

We are considering the following deployment architecture:

Run multiple ngrestserver processes (each on a different port)
Place nginx in front as a reverse proxy / round-robin load balancer
Rely on process isolation to avoid concurrent access to globals

The core question: To assess whether this model is safe, we need clarity on ngrestserver’s internal request concurrency:

Does ngrestserver:

Handle requests sequentially in a single thread, or
Spawn multiple threads, or
Use a thread pool / asynchronous dispatch internally?
Can a single ngrestserver process execute multiple REST handlers concurrently?

Is there any configuration option (build-time or run-time) to:

Limit ngrestserver to one request at a time, or
Disable internal threading if it exists?

If ngrestserver processes requests concurrently within a single process, then:
All REST handlers must be fully reentrant and thread-safe
Global state must be protected or refactored
If ngrestserver is single-threaded per process, then:
Running multiple ngrestserver instances behind nginx provides a safe and controlled migration path for legacy code

Assumptions (please correct if wrong)

ngrestserver is designed as a lightweight standalone HTTP server
nginx reverse-proxying to ngrestserver is a supported deployment pattern
ngrest does not require handlers to be explicitly asynchronous

Any clarification (or pointer to the relevant source files or documentation) would be greatly appreciated.

Thank you for your time and for maintaining ngrest.
Raajesh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions