Troubleshooting
Latency issues with API using Cloudflare proxy
As I started to serve my service as a beta testing, some customers complained about latency issues.
First, I thought it was related to the business logic. I improved the performance of the API, and the latency was reduced by 5 ~ 10%.
However, the latency was still high, over 300ms, so I started to investigate the root cause.
Finally, I found that the latency was caused by the Cloudflare proxy.
There were many references about this issue on the internet, and the latency issue was gone when I disabled the proxy.
I'm still not sure that it is safe to disable the proxy, because the home server is directly exposed to the internet.
However, the latency issue is definitely important, because it is on production. I determined that I have no choice but to keep the proxy disabled.