Design: How to Solve 503 Error of API when Resources are not available?

in #programming5 years ago (edited)

*Reposted to Blog

The HTTP 503 Error indidicates the server is busy. It might be due to the fact that the servers are overloaded (high load average).

One of my API is designed to return 503 Error when the cached file is not available. It is designed as the follows:

if (!is_file($file)) {
    throw_503();
    die();
}

The $file will be updated periodically e.g. every minute via Crontab. When the OS is writing to that file, the is_file will return false because the file is in-use.


Every little helps! I hope this helps!

Steem On!~
*Reposted to Blog


If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com

Sort:  

支持行长拍手支持👏
行长能不能请你去matters上给我的「让爱发电」文章投票一个likecoin支持啊!我在参加matters上的一个活动呢😜拜托了!先感谢哈🙏

感谢,回赞!
可以的。这就去。

Coin Marketplace

STEEM 0.12
TRX 0.34
JST 0.033
BTC 119956.46
ETH 4439.59
SBD 0.79