Part 2 ended with a working routing foundation: an OpenTripPlanner (OTP) graph built from OpenStreetMap and GTFS, answering journeys across Nairobi. The next question is the one every deployment eventually faces. What does it cost to run, and what breaks first as it grows?
It is tempting to answer from intuition: "the transit network is the hard part", "more routes means slower searches", "a bigger country needs a bigger server". Some of that turns out to be true. Some of it is the opposite of what the measurements show.
This article profiles a real deployment, with numbers from its build logs and from a benchmark against the running server. The aim is a mental model of OTP's costs that you can apply to your own network.
1. The setup being measured
Everything below was measured on the graph that serves Navigo's journey planner in Kenya.
Input | Size | What it is |
|---|---|---|
| 351.7 MB | The whole country's street network, from Geofabrik |
4 Copernicus GLO-30 tiles | 38.6–40.2 MB each | 30 m elevation for Nairobi metro and the Naivasha–Nakuru corridor |
Navigo's GTFS feed | 0.7 MB zipped | 147 routes, 295 trips, 4,321 stops, 11,914 stop times, 792 frequency rows |
The GTFS feed deserves a second look. 134 of those routes are matatu routes and 11 are rail (the SGR's Madaraka Express, the Nairobi Commuter Rail lines and the Safari trains). Most matatu trips are not timetabled. They are described by headways in frequencies.txt:
trip_id,start_time,end_time,headway_secs,exact_times
10106110,06:00:00,09:00:00,300,0
10106110,09:00:00,15:00:00,900,0
10106110,15:00:00,21:00:00,300,0One trip row, three rows of frequencies: "every 5 minutes at the peaks, every 15 minutes in between". Keep that in mind. It explains the most important result in this article.
The resulting graph has 1,248,102 street vertices and 3,122,550 edges, plus 4,321 stops and 286 trip patterns.
The machine: OTP 2.10.0 on Java 25, in Docker, on a laptop with an Intel i7-10850H (6 cores, 12 threads). The production server is different, so treat the absolute times as one data point and the ratios as the findings.
2. The build: 17 minutes, and transit is 16 seconds of it
OTP has two modes: --build --save compiles graph.obj, --load serves it. The build log timestamps every phase, so the profile can be read directly from it:
Phase | Duration | Share |
|---|---|---|
Parse OSM (relations, ways, nodes: three passes over 351.7 MB) | 7 min 03 s | 41% |
Compute way properties (866,638 ways) and build the street graph | 3 min 50 s | 22% |
Elevation (4 tiles, one pass each over 3,105,189 edges) | 1 min 53 s | 11% |
Island pruning (walk, bicycle, car) | 1 min 39 s | 10% |
Indexing, stop linking, turn restrictions | 54 s | 5% |
Write | 52 s | 5% |
Data import issue report | 22 s | 2% |
Read GTFS, validate stop times, build trip patterns | 16 s | 1.6% |
Startup, config, transfers, checks | 17 s | 2% |
Total | 17 min 06 s |

The street network accounts for about 84% of the build. The entire transit network, the part that makes this a journey planner rather than a street router, takes 16 seconds.
Three practical consequences follow.
Publishing a timetable change costs as much as rebuilding the country. OTP 2 has no incremental build: any change to a GTFS feed means a full --build. If your operators edit routes several times a day, the street network sets your publishing cadence, not the size of the change.
The elevation phase scales with the number of tiles, not the area they cover. The log shows four separate passes, each walking all 3.1 million edges (about 28 seconds per pass), even though most edges sit outside any given tile. Merging the four GeoTIFFs into one before the build would turn four passes into one. That's a cheap optimisation that's easy to miss.
Island pruning is doing real work. It found 5,049 disconnected walking "islands" and removed 17,396 walking edges, and 9 of the islands had transit stops on them, which OTP reconnected. Those are places where a stop would otherwise be reachable only from a fragment of footpath. The build report (report/GraphIslandWALK*.geojson) is worth opening on a map before you trust walking access to a new area.
The build ran with a 6 GB heap (-Xmx6G). The OTP documentation's general advice holds: the build needs noticeably more memory than serving.
3. Startup and memory
Serving means loading graph.obj back into memory. Four restarts of the same graph on the same machine:
Start | Graph loaded | Ready for routing | HTTP up |
|---|---|---|---|
1 | 25.9 s | 34.5 s | 38.2 s |
2 | 35.8 s | 51.1 s | about 52 s |
3 | 46.6 s | n/a | 63.8 s |
4 | 61.5 s | n/a | 78.5 s |
Between 38 and 79 seconds, mostly deserialising the graph and rebuilding the street index (8 to 14 seconds for 1.25 million vertices). The spread comes from the machine's disk cache and whatever else is running. On a smaller production server, plan for one to two minutes. Your health checks and deploy scripts must tolerate that window.
Idle after the benchmark below, the serving container used 2.37 GiB of memory with a 4 GB maximum heap. That's the number to size against: a Kenya-wide graph with elevation fits comfortably in a 4 GB heap.
One budget rule falls out of these two measurements. A build needs about 6 GB and a server about 2.5 to 4 GB. If you want to build a new graph while the old one keeps serving, you need both in memory at once. Part 4 comes back to that trade-off.
4. Query latency: the search window decides everything
Now the part users feel. I sent the exact GraphQL query the application uses (planConnection, 8 itineraries, transfer and walking preferences as in production) for six real trips at 08:00 on a Monday. Each trip ran with five values of searchWindow, five runs each after two warm-up requests; the table shows the median in milliseconds.
Trip | 30 min | 1 h | 2 h | 4 h | 6 h | 6 h ÷ 30 min | Itineraries |
|---|---|---|---|---|---|---|---|
Kencom → Yaya Centre | 61 | 127 | 311 | 574 | 1,139 | 19× | 1 |
Ruiru → Junction Mall | 90 | 178 | 342 | 730 | 1,308 | 15× | 1 → 3 |
Kikuyu → Kenyatta Avenue | 96 | 152 | 239 | 474 | 802 | 8× | 1 |
Rongai → Kencom | 154 | 285 | 546 | 1,447 | 3,254 | 21× | 4 |
Kitengela → Westlands | 307 | 551 | 1,412 | 4,318 | 9,181 | 30× | 5 → 8 |
Westlands → South B | 371 | 605 | 1,379 | 4,486 | 11,969 | 32× | 8 |

For Westlands → South B, the 6-hour window is 32 times slower than the 30-minute window (12 seconds against 371 ms), and returns the same 8 itineraries, byte for byte the same size. For Kitengela → Westlands it's 30 times slower, for three extra itineraries that leave hours later.
Why the window costs so much
OTP 2 searches transit with Range RAPTOR. Instead of one search from one departure time, it runs the RAPTOR rounds for every minute in the search window, from the last minute back to the first, reusing work between iterations. That is what lets it return several departures in one request. It also means the cost grows with the window: a 6-hour window is 360 departure minutes; a 30-minute window is 30.

On a timetabled network with a train every hour, most of those 360 minutes find nothing new and are cheap. On a matatu network, they aren't. A route running every five minutes generates a new boarding opportunity every few minutes at every stop, so each iteration has real work to do.
The table shows how that depends on the trip. Kikuyu → Kenyatta Avenue is a single radial route: doubling the window roughly doubles the time, and six hours cost 8× as much as thirty minutes. Westlands → South B crosses the densest part of the network, where several routes and transfers compete: each doubling of the window costs more than double, and six hours cost 32×. The cost of the window grows with the density of service around the trip, which is exactly where riders search most.
And it buys nothing. When the next matatu is five minutes away, a passenger leaving at 08:00 does not need options for 13:30. The answers in hour six are the same routes shifted in time.
So the window is now 30 minutes for anything that includes buses, and it's sent with every request rather than left in the server's config:
'searchWindow' => str_contains($otpMode, 'BUS') || str_contains($otpMode, 'TRANSIT')
? (int) config('transit.otp.search_window', 1800) // 30 min
: (int) config('transit.otp.rail_search_window', 21600), // rail only: 6 hRail-only searches keep a 6-hour window. Trains run a few times a day, so a short window would show only the next one, and with no matatus in the search, a long window stays cheap.
This is the same lesson as the build profile, seen from the other side: the shape of your data, not its size, determines the cost. 295 trips is a tiny feed. Frequency-based service makes it expensive to search.
The other requests are cheap
The application does more than one search per journey. Two of the extra requests are worth measuring.
Diversity passes. Matatus run so often that OTP's best answers are often the same route at 08:00, 08:05, 08:10. To show genuinely different options, the API re-asks OTP with the routes already found excluded (Part 5 covers this). One such pass costs 81 to 446 ms with a 30-minute window.
Direct street routes. Walking, cycling and driving with no transit (directOnly) took 10 to 200 ms per request, even across 20 km of city. Street routing in OTP is A* on a static graph, and it's fast.
5. What actually limits OTP as the network grows
Part 2 promised a comparison of a city-sized graph with a larger geographic one. The profile above answers most of that question, because it shows that "the network" grows along three independent axes, and each one hits a different limit.
1. Geography (the street network): build time and memory. About 84% of the build and most of the heap is OpenStreetMap. A Nairobi-only extract (the osmium extract --bbox recipe in the OTP README) would cut the OSM phases roughly in proportion to its size, which is the right choice for a development machine. But serving the country costs 2.4 GB, which is affordable. Geography decides how often you can afford to rebuild, not whether you can serve.
2. Transit density (departures per hour, not routes): query latency. Our 147 routes are a small feed. Their frequency-based service is what makes queries expensive, through the search window. Doubling the number of routes in another city would add a few seconds to the build; doubling their frequency would roughly double the cost of every long-window query.
3. Concurrency: threads. OTP's HTTP server sizes its handler pool from the CPU count (15 threads on this 12-thread machine), and each transit search is CPU-bound. A server that answers one search in 400 ms doesn't answer 100 concurrent searches in 400 ms. That's where caching (Part 5) and capacity planning (Part 8) come in.
Two router settings act as guard rails, whatever the cause:
{
"server": { "apiProcessingTimeout": "PT15S" },
"routingDefaults": { "streetRoutingTimeout": "PT5S", "searchWindow": "PT30M" }
}A pathological request now fails in 15 seconds instead of holding a thread for 46.
6. How to benchmark your own deployment
The method matters more than these particular numbers. What worked:
Read the build log as a profile. Every OTP phase logs its own duration ("done in 2m38s…"). You don't need a profiler to see where the time goes.
Benchmark the query your application actually sends, not a minimal one. The GraphQL selection set (geometry, steps, intermediate stops) changes response sizes from 4 KB to 85 KB.
Use real origin–destination pairs that cover short urban trips, long radial trips and cross-town transfers. They behave very differently: at a 6-hour window the cheapest trip here took 0.8 s and the most expensive 12 s.
Warm up, repeat, and report medians. The first request after a restart pays for JIT compilation and cold caches.
Change one parameter at a time, and check that the answers stay the same. A faster search that returns different itineraries isn't an optimisation, it's a different product. (When I tried relaxing walking preferences to speed things up, a 98-minute walking option came back.)
The script I used is about 100 lines of Python with no dependencies: for each pair and window, post the query, time it, and record the itinerary count and response size.
The conclusion for Kenya
The intuition that "transit is the hard part" is right about data quality (Part 2) and wrong about build cost. The street network dominates the build and the memory; the transit network dominates query latency, and only because of how frequently matatus run.
That shifts where engineering effort should go. Shrinking the graph is a development convenience. Choosing the search window, and owning the pipeline that rebuilds the graph whenever the data changes, are production concerns.
Part 4: Owning the Data, from a Transit Database to a Published Graph covers that pipeline: keeping a city's matatu network in PostgreSQL, validating it, exporting it as GTFS, and rebuilding OTP safely without taking journey planning down for good if a build fails.
Technical references
OpenTripPlanner: configuration of the router, including
searchWindow.Delling, Pajor and Werneck, Round-Based Public Transit Routing (RAPTOR), Transportation Science, 2015.
GTFS
frequencies.txt: headway-based service.Copernicus DEM GLO-30: the elevation model used here.





