I've seen similar issues over the past several weeks (2 to 3), and they seem to be relating to php being used in conjunction with mysql (either of the process may be stalling), but I have also seen weird I/O Wait spikes in my NewRelic server monitor that seem to occur at the same time. Not quite sure what to make of that.
@NexPB I have the same problem -- am also on DigitalOcean. I get these spikes in resource usage, that sometimes culminate in the server becoming unresponsive, but not sure what is causing it. The only remedy I have found so far is to reboot the server (since its a production server, we don't have the luxury of keeping our site offline while we do extensive debugging).
In all my years of using Apache/Nginx and php-fpm, I've never had it go above 10%. I run multiple large websites on a single dedicated server. Which VPS are you using from DO?
You would need some serious traffic to make the $20 a month plan worth it.
Your edit: chances are it is a bad query or something similar. Look at your logs to make sure there aren't any errors being thrown by your users that you are unaware of and if you are using google analytics match the times of the spikes with the traffic flow and see what users are doing to cause such issues.
@NexPB I'd actually consider getting something larger than that... Even if someone spams your site with a Layer 7 attack, it will reach 60% on fpm workers. If I hold down refresh on one of my sites (forum with a bit of caching) it spikes to 40% on a Xeon E3 quad core.
Running on digital ocean here too - I found the 64bit versions of Ubuntu to be flaky with php5-fpm. Without being too scientific, I swapped over to 32bit and things seem to run better.
@bashy I'm now creating a 80$/month plan droplet and see if it gets any better. If I'm still getting the same issue there has to be something else to it since I never had this issue before.
@Kryptonit3 I'm using just Nginx right now, also I'm working right now on trying to optimize everything in the server side while switching to laravel 5.1 from 5.0
@bashy What is the ubuntu command to check the concurrent connections?
To everyone: I change my droplet and it ran really fine again for a few hours and then suddenly it starts spiking again...
There's no command for that but you can use something like Google Analytics.
Looks like someone is attacking your site though. 100Mb/s out is 12.5MB/s so 12 people loading a 1MB file every second. Could be a Layer 7 attack (GET/POST).
If it's from the same ip you can use the new throttle feature on requests per minute. Setting it high shouldn't affect real users, but not allow repeated requests to execute anything (redirect to 404?). If your stats show average client requests per minute (keeping in mind the number will be inflated if attacks are happening) to just above that number.
There are paid services that filter your traffic for you too.
If you have a DDoS try lighttpd with mod evasive, had better results with it stopping DDoS attacks than nginx.
Then either add globally
server.kbytes-per-second=1024
or per virtual host
$HTTP["host"] == "example.com" {
server.kbytes-per-second = 64
}
Lighttpd has more traffic shaping settings out of the box. You can also run it as a reverse proxy over nginx so then it would be just a matter of a few minutes to get it up and running.
@bashy I'm guessing I may have had something in either my nginx config, or php config wrong, but I was running into issues with php5 fpm locking up entirely. The only thing that would bring back the site back would be to reload php5 fpm. This would fix for a completely random timeframe, maybe a day, maybe no more than 10 minutes. After a few weeks of this, I tried a last ditch at 32bit Ubuntu, and it seems to be working at the moment. Maybe just creating a new VPS fixed it, I just don't know for sure.
I concur with the "bad Mysql query" suggestion. I have converted all my "legacy scripts" to artisan commands now, that use Eloquent instead of direct mysqli queries (which were very inefficient the way they were written) and will monitor from here. I have noticed that running console php is much faster than running php-fpm, so I'm hoping it will reduce the load by not having to go through nginx and php-fpm, etc. to run.
Could you maybe post your nginx and php-fpm configs? It is entirely possible that some sort of config quirk is causing your load to spike like that. Unless it really is an attack, then I guess only caching will have a real impact.
DO is a not an ideal VPS host for actual projects. It was a mess when I hosted my sites on it. Linode is a better option in regards of service quality and data recovery. However, it's just from my own understanding.
@lyesqiz What makes you say that? DO and Linode both give you a fully featured virtual machine which allows you to install whatever you want. You can have the exact same system up and running on any of those services. What are the points that where negative about DO for you?
I do have several projects hosted on DO. One customer site for example runs a company blog and easily survived the Reddit effect several times over.