Replacing/updating a map file via socket commands

Howdy - we use large map files for a variety of purposes, and they change regularly throughout the day.

We currently do a zero-downtime restart on a loop every X seconds to pick up the changes, which means a delay between map file changes and haproxy using them. It also means a spike in memory, which isn’t a dealbreaker.

I’d like to reflect the map changes more quickly. Our map files have 100k+ entries, and many change occur throughout the day. Is there a way to efficiently switch/replace/reload map file contents using the socket commands?

I’m playing with show map prepare map set map etc, but with the sheer volume I’m hoping for a bulk mechanism. Maybe continual restarts are still the best way, but it feels like the socket commands are really close to what we need.

We’re on 2.8 LTS right now.

Thanks!

Prepare map + set map (with the revision id) + commit map (rev id) would be the way to go for updating multiple entries at once and reducing the lock window to the bare minimum.
With prepare map you get a revision id which can be used to temporary build a new map revision alongside the running one, then you get to populate it as you wish, and when you’re done with the changes, commit it to replace the live one with the given revision atomically. This is what’s recommended for bulk updates.

Directly updating the live map with set-map is indeed very costly because each set would then lock the table during the update.

Ok; I was hoping for something that didn’t require looping over 100k add map calls, but we can work with that.

Thanks @adarragon!

FYI, with haproxy 3.2 it will be possible to group updates by leveraging the add_bulk() Patref method from lua