Task: Set up OSRM server
Set up OSRM server
OSRM (Open Source Routing Machine) is an extremely cool thing! It allows you to pre-process all possible routes based on a provided OSM (Open Street Map) database and then calculate routes on the map very quickly, supporting multiple waypoints at once. For my tourism project, this thing is simply irreplaceable.
GitHub project: https://github.com/Project-OSRM/osrm-backend
Demo site: https://map.project-osrm.org/
But here's an important point: preparing these routes requires quite a lot of computing power. Last year, I was preparing routes for 4 countries at once (Vietnam, Thailand, Laos, Cambodia). First, I ran this on my personal laptop (meaning the one I use for myself, not provided by work), and it is definitely not a weak machine (14th gen Core i7, 64 GB RAM). Here is what happened to it:



In other words, it lacked resources and the process kept crashing.
OK, I had recently bought a more powerful PC for AI experiments, which has significantly more resources — a Core i9 and 128 GB of RAM. And not that I was very surprised, but it couldn't handle it either :-) The process devoured all 128 gigs of RAM and 8 gigs of swap.

OK, going all in :-) I set up a 1:1 swap relative to RAM, meaning 128 GB RAM and 128 GB swap. Long story short: it handled it :-) But peak memory consumption was 190+ GB :-)

However, it finally finished and generated all the routes for me. True, the final database for those 4 countries weighs 100+ GB. Meanwhile, just Vietnam alone is only 5 GB.
du -hs *
101G asia
5.3G vietnam
By the way, it also consumes quite a few resources during runtime. The container for just the Vietnam routes consumes around 3 GB of RAM upon startup.