Use varnish+nginx+lua to build a website downgrading system
foreword Usually after a website database hangs up, the consequences will be very serious. Basically the entire site is basically unusable. For some websites, it would be nice if they could provide basic browsing services when the database is down. This article will try to use varnish + nginx + lua to build a website downgrade system to achieve the whole goal. relegation target The goal of the downgrade solution is to display the cached page data to the user when a fatal failure occurs on the website (for example, a 500 error occurs and the service cannot be provided). This provides basic browsing services. 1. Only provide basic browsing services 2. The browsed data is all data in the non-login state 3. Support manual and automatic downgrade. Automatic downgrade is when the backend returns 500 errors and reaches a certain threshold within a period of time (excluding 503). Manual downgrades are performed from the control interface. downgrade plan storage Use varnish as storage. It effectively saves physical memory and maintains good performance. renew Use the crond script to analyze the request URL from the nginx access log, and then send a request to Varnish to update Varnish’s cache. The…