How to test speed between web servers - php

my web pages are hosted on company A. I have moved to company B. My account at company A will be active for a few days. How can I test and therefore compare the speed of those two?
Thank you.
I am using webserver through cPanel, so I guess a PHP script or something would be great.

you can use JMeter. easy to use. you can have some regression test for various scenarious which you actually want to do. ie: see how web servers perform under different loads and compare the companies.
Or you can use Pingdom tools even firebug will give you how long each web server takes to load the same resources.
Note that, your speed tet mostly will depend on latency, ie: your distance to one webserver vs the other one. Plus how many applications are running in one server on company A vs the other server on Company B if that s shared hosting.

As mentioned before:
See the 'hops' to your server with traceroute or tracert
There are some great server tools like Nagios which will give you a LOT of info about the server & network.
If they are your own servers you could even try a DDOS attack on them to see how much stress they can take.
You could simply run a php script with 50k loop iterations of different actions like file I/O, database queries etc etc to see how the 2 servers compare in milliseconds wit the different actions.
You could setup a jsperf script to run a few hundred ajax requests to see how each perform.
It really depends on what you suspect to be the problem? There are tools & methods to test each thing (network, hardware storage, cpu etc)

If you are using apache have a look at ab the benchmarking tool.

You can also do tracert or traceroute depending on the OS you're using to test the actual connection speed.
For the server speed itself, you can monitor your scripts directly inside of them (start a timer at the beginning of the load and display it when the page loading ends).
There are several things to consider on a "server speed", not only the horsepower :)

Related

How to do load testing of a PHP website from both ends

We have developed a website in PHP for small services. Before production, we have to do performance and load testing from server side (that is Apache) and from client side.
From Client side, I want to know what is the average response time overall and for each object etc. For back-end side (apache web-server), I want to know how many request (clients) it can handle before its performance start to degrade.
Is there any open source tool as we are on Linux platform, for this purpose. Or is there any website(s) available (freely) that can do all of these testing.
We are more concerned about load testing where we want to request to our website from 1000 users at same time (for example) and want want to check client and server side different performance metrics.
Since you are running Apache, you could use ab to stress test the server side of your application.
Apache HTTP server benchmarking tool
ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.
Let's look an example:
ab -k -c 100 -n 10000 example.com/
By issuing the command above, you will be hitting http://example.com/ with 100 simultaneous connections until 10 thousand requests are met.
Here you have another tutorial how to use ab
Stress-Test Your PHP App With ApacheBench
Some other helpful tools are:
Apache JMeter
httperf
If you want a more in-detail view of your php objects and all that stuff I would suggest you to check blackfire. As I know they offer a free version for local testing and only one application. But I don't think that you need this one for now.
For your front end I would suggest you a set of tools that help you to see how your page performs in different devices:
Lighthouse
PageSpeed Insights
Pingdom
You can find the list of free and open source load testing tools at http://www.opensourcetesting.org/category/testing-tools-overview/performance/?menu-page=overview, currently there are 59 (and counting).
The narrowed down list of the most advanced cross-platform open source load testing tools can be found in Open Source Load Testing Tools: Which One Should You Use? article, it also has feature comparison matrix, sample scripts and reports.
Given your application is in PHP my expectation is that you don't have a lot of expertise in other programming languages so the most obvious choices would be in:
Tsung where you can create your load test using XML files
Apache JMeter which also stores test scripts in XML format, however you can use GUI for test logic creation which might be faster and easier.
Both tools provide record-and-replay functionality so you will be able to build your test scenario skeleton using browser.

How to test PHP social networking scalability

I have developed a Social Networking website based on WAMP(Windows, Apache, MySQL, PHP) server. I put it up on a Free Host (the hosting serves it in LAMP), and it works fine.
Now, I researched a little and found out that PHP applications are difficult to scale, and take a lot of parallel algorithms. I would like to test how many users does the webhost support for my website, and how much does my localhost.
It's a social network like any other, involving:
Posting data on main page(with images).
Chat between users (with polling every 3 seconds, consider as one in
facebook).
A question-answer forum(just as this one, or yahoo answers -
including upvotes,downvotes, points etc)
Two HTML5 server sent event loops running infinitely.
Many AJAX requests for retrieving data from MySQL database.
As for now, I haven't applied any Cache options, which I plan for later. Also, the chat application has to be switched from Polling to Websockets(HTML5).
My estimated user database goes to be a lot more than 100,000 users. That may need some serious scalability.
I need to know what kind of server may I need for the same. Should it be a dedicated server, should it be 2 of 'em or even more?
I tried this ab.exe located in bin folder of Apache, but it tests the location we provide manually. A social network needs login information to access all the data, which unfortunately limits the functionality of ab.exe only to availability of the "Welcome" page, and nothing towards the AJAX and HTML5 features which I mentioned above.
So, how exactly should I test the scalibilty of website for a hardware same as my laptop(Windows, Intel i5, 4gb Ram, 2.0 GHz), and what about scalability on Shared servers available out there, or even the dedicated ones.
Simply put: You are counting your chickens before they hatch. If you become overwhelmed by a bunch of new users, then that is what we tend to call a "good problem". If you're worried about scalability along the way, then you should look into:
Caching with Memcached or Redis.
Load balancing.
Switching from Apache to Nginx.
Providing a proper CDN.
Since you're using PHP, you should install an opcache.
There are a lot of different ways to squeeze out results. Until you need them, I'd suggest sticking by best practices (normalization, etc).
If you are worried about the capacity of your hosting company to cope with your application then the first thing to do is to contact them and discuss what capacity they have available and how scalable their environment is.
Unless you are hosting yourself, then you have virtually no control over the situation.
But if you believe the number of users is going to grow very quickly then it would be wise to enter a dialogue very early with your provider.

What are the ways to test a php site's performance for load?

Is it possible to test a php site's performance for hundred thousands of users before it actually achieves that user base?
What are the tools? Can it really be realistically judged based on these tools?
You don't say much about your server setup. How many servers? What OS? Which databases?
Well, for a start, you might want to try „ab“, the Apache HTTP server benchmarking tool.
http://httpd.apache.org/docs/2.0/programs/ab.html
You can simulate any number of concurent requests. Best thing would be to write a test suite that simulates a number of typical user activities: sign-up, sign-in, post something, download some file and the like. Then you can run this test suite from a number of clients at the same time and simulate some hundred or thousand users simultaneously.
Then take a look at your server system and see how it performs. Log data to find bottlenecks and improve your system iteratively.
There's also Seige
https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5171727.html
xl-t's suggestion of apache bench (ab) is good for quickly pounding on a script or two. That's a good place to start.
There's also siege, which is a little more sophisticated.
If you want to get fancy, and have easily repeatable tests, you should have a look at jmeter. The learning curve is a little steep at first, but it can model/simulate a huge number of scenarios. It's got a GUI, but the GUI be configured to run the tests from a remote box. Ideally, you'd use a server that's close to your web app's server.
Running any tests from your local machine is likely to benchmark your network connection rather than your application.

Super fast server for php script

I have a php script which requires no web hosting or disk space etc.
The script simply retrieves infromation from a server, does some processing on this information
and than passes it on to a client (an iPhone app in this case).
The only thing is that if traffic gets high than there is a high demand for bandwidth and speed.
Does anyone know of a service with high speed and badwidth (apart from web hosting services) that allows you to host (on a static ip) such a php script?
Thanks.
You may want to try some sort of cloud service where you can set up the environment you actually need. Let's say your script need a lot of RAM but only little CPU power (or the other way around) you can have exactly such a system. Amazon EC2 is one of many cloud computing providers out there.
hmm the performance point you can use something like "Facebook HipHop" to convert your php script into "c++" then you have the performance you need.
Cloud solution is perfect. You can even write shell scripts to increase decrease RAM whenever demand goes up.
Like everyone here mentioned, cloud hosting is your best bet. It's slightly more expensive for resources & bandwidth than a dedicated but is superior in performance/latency/scalability. I have a similar application setup for a current project and I am running on the RackSpace cloud with 100K+ active users on a daily basis and I have had no problems (been running for 6 months).
If your code is simple, don't use Php !
You can consider:
Python
GWan server + C
Java
Php is good for big project because its simple, fast to use/test/debug ...

Does a separate MySQL server make sense when using Nginx instead of Apache?

Consider a web app in which a call to the app consists of PHP script running several MySQL queries, some of them memcached.
The PHP does not do very complex job. It is mainly serving the MySQL data with some formatting.
In the past it used to be recommended to put MySQL and the app engine (PHP/Apache) on separate boxes.
However, when the data can be divided horizontally (for example when there are ten different customers using the service and it is possible to divide the data per customer) and when Nginx +FastCGI is used instead of heavier Apache, doesn't it make sense to put Nginx Memcache and MySQL on the same box? Then when more customers come, add similar boxes?
Background: We are moving to Amazon Ec2. And a separate box for MySQL and app server means double EBS volumes (needed on app servers to keep the code persistent as it changes often). Also if something happens to the database box, more customers will fail.
Clarification: Currently the app is running with LAMP on a single server (before moving to EC2).
If your application architecture is already designed to support Nginx and MySQL on separate instances, you may want to host all your services on the same instance until you receive enough traffic that justifies the separation.
In general, creating new identical instances with the full stack (Nginx + Your Application + MySQL) will make your setup much more difficult to maintain. Think about taking backups, releasing application updates, patching the database engine, updating the database schema, generating reports on all your clients, etc. If you opt for this method, you would really need to find some big advantages in order to offset all the disadvantages.
You need to measure carefully how much memory overhead everything has - I can't see enginex vs Apache making much difference, it's PHP which will use all the RAM (this in turn depends on how many processes the web server chooses to run, but that's more of a tuning issue).
Personally I'd stay away from enginex on the grounds that it is too risky to run such a weird server in production.
Databases always need lots of ram, and the only way you can sensibly tune the memory buffers is to have them on dedicated servers. This is assuming you have big data.
If you have very small data, you could keep it on the same box.
Likewise, memcached makes almost no sense if you're not running it on dedicated boxes. Taking memory from MySQL to give to memcached is really robbing Peter to pay Paul. MySQL can cache stuff in its innodb_buffer_pool quite efficiently (This saves IO, but may end up using more CPU as you won't cache presentation logic etc, which may be possible with memcached).
Memcached is only sensible if you're running it on dedicated boxes with lots of ram; it is also only sensible if you don't have enough grunt in your db servers to serve the read-workload of your app. Think about this before deploying it.
If your application is able to work with PHP and MySQL on different servers (I don't see why this wouldn't work, actually), then, it'll also work with PHP and MySQL on the same server.
The real question is : will your servers be able to handle the load of both Apache/nginx/PHP, MySQL, and memcached ?
And there is only one way to answer that question : you have to test in a "real" "production" configuration, to determine own loaded your servers are -- or use some tool like ab, siege, or OpenSTA to "simulate" that load.
If there is not too much load with everything on the same server... Well, go with it, if it makes the hosting of your application cheapier ;-)

Categories