Amazon Web Services EC2 Instances Become Painfully Slow From Time to Time - wordpress

I am using the free tier for now and have noticed that the servers on which I host a couple of Wordpress sites become periodically and painfully slow to respond if I access the sites through the browser. Accessing the admin of the site becomes impossible. That said, I can still quickly SSH to the servers, if needed.
What can be causing such a behavior? I have seen short bouts of this previously but the current one has lasted for over two days. I have tried recreating the servers, rebooting them, etc. Needless to say, unless I am doing something wrong, it is making me question the decision to try AWS for these projects.

This is from the amazon site:
T2 instances accrue CPU Credits when they are idle, and use CPU credits when they are active. T2 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst
Worpdress sites are CPU intensive and not suiteable for this kind of environment. I have tried it before and learned quickly that t2.micro is good for two things. Light development or cached html content. Anything beyond that you are asking for trouble.
You need to upgrade beyond the free tier if you want some results. Otherwise convert your site to a simple html website, or cache the heck out of your content.

Related

EC2 Instance running a news website has major performance issues

We are running a regional news website (https://www.galwaydaily.com/) on an AWS EC2 instance (t3 medium).
The problem is that the page load speed over the past few months has gone up and up and a few days ago the site stopped working altogether for a few hours. In the past, we would just have scaled up the instance, but I'm not sure this is best practice.
Here is a screenshot of our CPU utilization for the past 2 weeks at 1 hours intervals:
I'd love some advice on how best to host and serve this site!
At a quick glance, your best option for the least amount of effort is to add a CDN. Your top 7 longest loading assets are a couple js/css files and then some images - none of which seem large enough to be taking as long as they do. Use a tool like GTmetrix.com to see if you are utilizing the resources you have effectively before resizing your instance and/or DB.
Other options include utilizing AWS features like memcache (I tend to use redis), Autoscaling groups and RDS.

Amazon Aws EC2 - Bitnami - wordpress configuration - extremely slow loading assets

I am trying to test out the feasibility of moving my website from godaddy to AWS.
I used a wordpress migrate plugin which seems to have moved the complete site and at least peripherally appears to be moved properly.
However, when I try to access the site, it is extremely slow. Upon using developer tools, I can tell that some of the css and jpg images are sort of acting as blocking threads.
However, I cannot tell why this is the case. The site loads in less than 3 seconds in godaddy, however, it takes over a minute to load it fully on AWS and there are at least a few requests that timeout. Waterfall view on chrome developer tools show a lot of waiting on multiple requests and I cannot seem to figure out what or why these requests are sort of waiting forever and timing out.
Any guidance is appreciated.
I have pointed the current instance to www. blind beliefs .com
I cannot seem to figure out if it is an issue with the bitnami wordpress AMI or if I am doing something wrong. May be I should go the traditional route of spinning up EC2 instance , run a server on it, connect it to a db and then install wordpress on my server. I just felt the AMI available took care of all of that tailoring without me having to manually doing it.
However, it is difficult to debug though as to why certain assets get blocked/are extremely slow and timeout without loading.
Thank you.
Some more details:
The domain is still at godaddy and I have not moved it to AWS yet, not sure if that is sort of having an impact.
I still feel it has to do with the AMI though - cannot prove it.
Your issue sounds like you have a free memory problem. You did not go into details on the instance size, if MySQL is installed on the instance, etc.
This article will show you how to determine memory usage on your instance. When free memory is low OR you start using SWAP space, your machine will become very slow. Your goal should be 0 bytes used in SWAP space and at least 25% free memory during normal operations.
Other factors to check is percent CPU utilization and free disk space on your file systems.
Linux Memory Check Commands
If you have a free memory problem, increase the instance size. If you have a CPU usage problem, either change the instance size or switch to another instance type. If you have a free disk space problem, create a new instance with a larger EBS volume OR move your website, etc to a new EBS volume sized correctly.

Hostgater shared hosting cpu usage problems

I have shared webhosting and sometimes i go over the max allowed cpu usage once a day, sometimes two or three times. but i cant really narrow it down to anything specific.
I have the following scripts installed:
wordpress joomla owncloud dokuwiki fengoffice
before i was just running joomla on this hosting package and everything was fine, but i upgraded to have more domains available and also hosted other scripts. now like wordpress, owncloud and so on.
but no site has high traffic or hits. most of the stuff is anyway only used by me.
i talked to the hostgator support team and they told me there is a ssh command to monitor or watch the server and see whats causing the problem.
the high cpu load just happesn for a very short peak, because everytime i check the percentage of cpu usage in the cpanel its super low. the graph shows me the spike, but it looks worse than it really is, because the graph gets updated only every hour, and that makes it hard to narrow it down...
i am new to all this. can somebody help me to figure this out?
BTW:
I hope this question is fine now here, kinda dont really understand this plattform yet...
Just so you have more information, I to host many websites with HostGator using a reseller/shared account. The performance of your site is most likely not an issue, and is related more to HostGator's new servers and it's poor MySQL performance. None of my WordPress sites had issues for years, despite high traffic/plugins etc. Fast forward to late 2013 after EIG purchased HostGator (and others like BlueHost) and the performance on the "new more powerful" servers is anything but. Limits on CPU and processes are more aggressive, and while outright downtime isn't an issue, the performance during peak hours is exceedingly poor. Sites which rely on MySQL databases all suffer from poor performance and no amount of caching or plugin optimization will help (I should know as I spent months reviewing my sites trying many optimizations).
My advice: Find another web host and/or upgrade your hosting to a VPS that can scale based on your needs.
I moved my higher traffic/important clients to WPEngine. The speed difference and quality support is massive.

Do websites in the same application pool share loaded libraries?

I have a Windows Server 2012 with IIS 8.0. It is hosting many small websites with a low user base which are not mission critical in any way. With small website I mean that the application code and memory footprint is quite low, but due to the loaded libraries, like EntityFramework, the memory consumption of the applications are about 140MB when freshly started and idle.
In general that’s not a big deal for a full-blown webserver, but I only have a VPS with 4GB of RAM which also runs several other applications (databases, BIND, hMail, etc.). I’m using it basically as development server to play with many different technologies. Therefore, I’m running out of RAM quickly while serving dozens of ~140MB w3wp’s.
Beside of suspending when idle I’d like to reduce the memory consumption while still using any framework or library I’d like to use – that’s the purpose of the whole thing actually.
Long story short: As the applications not only share the same .NET version but also some libraries like EF or MVC, would it make more sense to run multiple sites in one app_pool so that they can share the libs? Or would each site load its own copy anyway (due to different Application domains like discussed here)?
Bonus question: when considering a hardware upgrade 1GB of RAM is 20$/month but putting the whole server on SSDs is 10$/month. While I do know that reading from page file is always much slower than reading from RAM I’m thinking about using a big pagefile on the SSD instead of buying 1gig of additional RAM for twice the price – again, speed of the websites isn’t critical, they should just work. Would that make any sense at all?
Looking at a w3wp Process (hosting multiple sites) in Process Explorer shows that it hosts several different application domains with different instances of the same assemblies loaded into memory. So moving the sites into a single AppPool may not help much.
But there is another option. In IIS 8+ you can share common assemblies across AppPools. If certain assemblies are used by multiple AppPools, they are loaded into memory just once and then aliased by the different processes.
Have a look at this bit from asp.net and this TechNet blog post
You have to do a little bit of setup work, but then it seems to work quite well.

Worker process taking high CPU%

All of my websites are hosted in IIS and configured with one application pool. This application pool consists 10 websites running.
It is working fine till today, but all of sudden I am observing that there is sudden up and down % in CPU usage. I am unable to trace out the problem.
Is there anyway to check which website is taking much load among all in the application pool?
Performance counters, task manager and native code analysis tools only tell part of the story. To gain a deeper understanding of what is happening inside your ASP.NET application you need to use WinDBG, SOS and ADPlus.
Tess Ferrandez has a great series of articles on tracking down what is to blame here:
.NET Debugging Demos Lab 4: High CPU hang
.NET Debugging Demos Lab 4: High CPU Hang - Review
This is a real world example:
High CPU in .NET app using a static Generic.Dictionary
You will probably want to separate your sites into individual application pools so you can identify and isolate the site that is causing the high CPU (but it already looks like you have a suspect so I'd isolate that one). From then you can follow Tess's advice and guidance to track down the cause.
You should also take a look at the logs to see if you're experiencing an unexpected spike or increase in traffic. Perhaps there's a badly behaved search engine site indexer nailing the site. If that's the case then maybe you need to (if you haven't already done so) create a robots.txt to prevent crawlers from indexing parts of the site that don't need to be indexed. On top of that if certain crawlers are being overly promiscious then just ban them. Perhaps consider a sitemap for google to tame and tune its activities.
If your server has reached it's max capacity, you will see CPU go up and down erratically because the GC will start trying to recover resources(cache..etc), which in turn causes your sites to work even harder. It's an endless cycle.
Have you been monitoring your performance counters? Do you have any idea what normal capacity is for your site? If you cannot answer these questions, I suggest you gather some perf numbers as soon as possible.
My rule of thumb is to always measure first, then make necessary changes.
Most of the time performance bottlenecks aren't where you think they would be.
There is really no performance counter way to tell, because the CPU counters are at the process level. Your best bet would be to do a time corelation with other events in the event log and .NET/ASP.NET counters for garbage collection, requests etc.
If you really want to go hardcore, you could use the SysInternals toolset to take snapshots of your app pool over time and then do a post-analysis to figure out what code was executed when the spike happened. Here is a related example from Mark Russinovich's blog - http://blogs.technet.com/b/markrussinovich/archive/2008/04/07/3031251.aspx.

Resources