Propose a better allocation strategy
Kea 1.6 and earlier always used the same allocation strategy: pick the first address/prefix, look into the DB whether it's available. If not move to the next address/prefix and try again. That works very well when the pool is mostly empty, but is very inefficient when the pool is mostly full as it requires many lookups.
Even with multi-threading, we would just do the same inefficient thing over and over again, just faster. The ultimate solution to this problem is to decrease the number of lookups.
The performance proposals for 1.7 list several ideas what could be done about it:
- keep free leases in the DB. That way we could do a single SELECT to return the first free/expired lease.
- alternative proposal calls for lease cache. We could do a single query and return all free leases in a pool. This would work great for single single-threaded instance, but it's unclear how to maintain this cache consistency among multiple threads or even worse multiple Kea instances connected to the same DB.
- stored procedure to return empty lease. This should improve the DB round trip time, but at the end of the day we would just repeat the same inefficient algorithm: when the pool is mostly full, the stored procedure would take a lot of time to complete.
Related ticket: #1126 (closed).