FokiDoki / WireRest

REST API for Wireguard
MIT License
18 stars 5 forks source link

Caching added, performance improved #46

Closed FokiDoki closed 1 year ago

FokiDoki commented 1 year ago

Caching

Now /peers and /interface are cached. This means that WireRest will not ask wireguard for a dump for every request. Therefore, if you add a peer not through WireRest, it will not appear in the api immediately, but after some time. Caching significantly improves performance on large configs (1000+ peers)

Params

Caching can be disabled with --wg.cache.enabled=false Synchronization period can be set using the --wg.cache.update-interval= parameter. Interface synchronization time is static and is 300s

Restrictions and Responsibilities

I strongly do not recommend creating peers bypassing WireRest when caching is enabled. WireRest will not know which ip address you took when you added a bypass peer, and a conflict may occur accordingly. He learns about the ip address only after he synchronizes, then everything will go fine. If you still add peers manually - assign them an ip address that is far from the last busy address, then WireRest will have time to synchronize.

Other

Sorting is disabled by default as it takes a lot of time on large configs

Load Test result

2500RPS to /peers / 1CPUx3300Mhz / timeout 10s / Config contains 25.000 peers

No cache: image Timeouts>95%, Average responce time > 10000ms With cache: image Timeouts=0%, Average responce time ~ 400ms