How a website should handle a database crash

I am currently creating a website in php with a database backend (maybe MySQL or SQL Server), and I recently realized that if my database crashes at any time, my site will not work properly and will probably cause some headaches.

So what needs to be shown on the website if my database (or some important external component) is down? My particular website relies heavily on its database and without it will be practically useless.

One of the options I was told about is to send an email to the website administrator and display the Error 500 page, which says that something is wrong with the server and basically makes the website unusable until the problem will not be fixed. Is there anything else I could do to get around this? Are there any ways to build a website so that the failure of the database (any important component) is not a problem?

I am looking for general general rules as well as concrete examples of how people have worked on this in the past. In addition, these examples do not have to be for my website.

+3
source share
3 answers

, - , : - , , .

:

  • ​​ .
  • , , .


( , ), , (MySQL ) : , , , .

, , .


, ( ), - , -: , , - .

, ( , ), , - ...

+5

HTTP 500 , - , - . - . , " " . , " ", 500, - .

, . .

apache, , :

http://httpd.apache.org/docs/2.0/custom-error.html

I recommend that you use plain HTML for your 500 code page code. You can also send your PHP page status code 500 through the header () function described here:

http://php.net/manual/en/function.header.php

+1
source

Source: https://habr.com/ru/post/1796129/


All Articles