Open-sourcing periodic upstream server resolution and implementing a dedicated service worker.

Neil Craig Neil.Craig at bbc.co.uk
Thu Jul 21 13:01:24 UTC 2022


Hi Vladimir

I hope you don't mind me chipping in here.
We currently have 2 services which use Nginx with upstreams whose DNS can change frequently (e.g. AWS S3, ELB/ALB origins) so we're familiar with this problem. Initially we did a config reload every minute to solve the issue but since then, we've created custom Lua (using the OpenResty Lua module) to achieve the same thing in a more efficient way.

What you're proposing sounds great to me. I wanted to suggest a few feature ideas for your consideration:

* DNS TTL-based refresh (rather than refreshing every N seconds)
* DNS prefresh (update DNS when the elapsed time since the last refresh is perhaps 90% of the TTL)
* IPv4/6 ignore (useful for example when there's a v6 IP available but the system/network doesn't support v6)

Cheers

Neil Craig (He/Him)
Lead Architect, BBC Digital Distribution
https://www.bbc.co.uk/blogs/internet/authors/1633673f-c77c-4bc6-b100-0664db0db613
https://twitter.com/tdp_org

´╗┐On 20/07/2022, 20:09, "Vladimir Kokshenev via nginx-devel" <nginx-devel at nginx.org> wrote:

    Hello!

    This is the two-part proposal to open-source periodic upstream server resolution
    and implement a dedicated service worker for nginx. The purpose of this e-mail
    is to describe the WHY and solicit feedback.

    Nginx supports domain names in the upstream server configuration.
    Currently, domain names are resolved at configuration time only,
    and there are no subsequent name resolutions.

    There are plans to open-source re-resolvable upstream servers.
    This will allow applying DNS updates to upstream configurations in runtime.
    So, there is a need to support periodic asynchronous operations.
    And a dedicated service worker is a possible architectural way to address this.

    The master process reads and parses configuration and creates the service worker
    when needed (in a similar way to cache-related processes).

    The service worker manages periodic name resolutions and updates corresponding
    upstream configurations. The name resolution relies on the existing nginx
    resolver and upstream zone functionality.

    The service worker will be responsible solely for periodic background tasks
    and wouldn't accept client connections.

    The service worker should be the last worker process to shut down
    to maintain the actual state of upstreams when there are active workers.

    Alternative architecture considered was about choosing one of the regular
    workers (e.g., worker zero) to take care of periodic upstream server resolution,
    but it creates asymmetry in responsibilities and load for this dedicated worker.

    --
    Vladimir Kokshenev

    _______________________________________________
    nginx-devel mailing list -- nginx-devel at nginx.org
    To unsubscribe send an email to nginx-devel-leave at nginx.org



More information about the nginx-devel mailing list