Application: Serve responsive and optimized images on the fly by cropping/resizing/compressing master images
Current Load: 10k request per minute, ~60MBps traffic.
Current Config : NginxPlus LB sits at the top. Multiple app servers with nginx->tomcat. On each app server images are cached in the nginx
Current Problems:
- Poor cache hit ratio as cache is decentralized, probability of same request hitting the same server is low.
- Duplicate caching, although this can be tolerated
- Cache purge is cumbersome. Since cache can possibly be present on multiple servers, For purging cache, It needs to be purged from all app servers
Potential Solutions
Nginx Load Balancer consistent hashing. The problem with this approach is that it may cause uneven traffic distribution
Introduce a mid layer of few nginx servers: A dedicated nginx caching layer can be introduced between LB and app servers. But Lets say i keep 3 servers in this layer, Still It has the same problem of duplicate caching and purge headaches although magnitudes lower.
Disk I/O might be a problem in case of single nginx
Does anyone has experience in solving this use case ? Be it not with nginx. Feel free to share your thoughts.