Mimic 'slowness' of web server on local computer - hosting

Is it possible to somehow mimic the slower download speeds of my website, as if it is hosted on a web server, but from my localhost?
It's hard to test things like Ajax loading icons when the content loads so quick from your local machine so I think this could help me out a lot?
I was wondering if there was a tool that you could use for this or if you'd need to use javascript to add setTimeout or setInterval code?

If you are using Windows, then download the Fiddler tool Fiddler.
This will setup a HTTP proxy that you can use for testing HTTP headers and view all the HTTP traffic within the PC and browser. You can then use the Rules > Performance > Simulate Modem Speeds option to slow the browser's HTTP connection.
There is also a Fiddler Switch plug-in for Firefox available to toggle the Fiddler proxy.

First of all, please never mangle your code with if ( DEBUG ) workSlowly(); statements. You will get bitten by this practice, and it will hurt.
Second of all, use one of the traffic throttling solutions which have already been posted here. I'm going to add a Java-based solution: Sloppy. It's dead easy to set up and runs everywhere where Java runs.

This question may help you out.
Personally, I add something like this at the top of my library file or whatever file always gets included:
if(DEBUG) {
sleep(2);
}
The above is PHP, but most languages are going to have something similar.

If you're on a *nix platform, you could alter the 'nice' level to basically make your process an afterthought behind most others until you achieve a level of 'lag' that is satisfactory to your needs.

One option is (if You are on linux, but other unix system have similar tools) Traffic shaping (google for 'HTB', 'qdics' and 'tc' command)
Second option will be apache_mod_cband module, this is also probably easer to get going.

You could try Charles. It's cross platform - I use it and it works really well.
http://www.charlesproxy.com/

On windows you can use Proxomitron or you can install fiddler (for ie). Both let you set the download speed.

If you use Fiddler 2, you can install this Add-On: Fiddler - Connection Simulator.
It gives you a nice UI to setup Bandwith and different simulation kinds.

Related

Load testing with different IE versions

I don't know if this question makes much sense but i would like to know if load testing can be done on different IE versions. For instance my product supports IE 8, 9 , 10.... Please clarify more on this.
Thanks.
When we do load testing, we are more interested in knowing the server performance. Not the client's browser performance.
JMeter itself acts like a browser. It sends the Http request & once it gets the response, it can display it like a browser(it does not execute javascript files though. It makes sense because javascript is going to be executed in client's machine.)
So, for your question, JMeter is not a tool for your requirement. You may have a look at the httpwatch which shows the page load time for the browser.
This only makes sense if
You build pages dynamically based upon browser type and version
If your load for your exceptional condition on page generation, which is typically early versions of IE, is significant
Simulating different browser versions is not always a requirement is performance testing, but could be needed in specific case. Do it if it really makes sense to do.
There are commercial tools which can easily simulate the different browser types/versions like LoadRunner, Microsoft Visual Studio etc. If you are going to use open source, trying mimicing the scenarios by providing browser details/properties in user agents header etc., just like the actual browser sends. You can capture this by checking the request headers from the browser (press F12 on chrome and see network)
The only thing you can do with JMeter is adding a HTTP Header Manager to send different User-Agent header value for each Internet Explorer versions. You can refer Understanding user-agent strings guide to see user agent values for different IE versions, however I don't think it will provide the full picture as JMeter doesn't actually "render" page.
So I would go the following way:
Use JMeter to put your server under expected load
Use one Selenium instance per Internet Explorer version to perform real browser testing of the system when it's under JMeter's load to measure performance differences.

Windows Programming - Hook the http request or the browser's messages?

There are some websites which make me waste much time so I want to block them by writing a hook program.
Can i do it?
Can i hook the http request of the OS or the browser's messages?
Well... you could but that would be the complicated way.
By far the easiest mechanism for blocking a site from a single computer is to edit your hosts file and change the DNS name to resolve to your local host.
Start Notepad.exe as administrator
Open the hosts file in c:\windows\system32\drivers\etc
at the bottom add a line like:
127.0.0.1 www.google.com
Save the file.
If you put in the exact thing I did above then you will no longer be able to get to google from any browser on your machine.
If you don't want the easy way, there are 2 other approaches.
One is system wide at which point you need to create a proxy server and modify the system to point to that proxy. Then you can decide what to do with the traffic. This is how Fiddler works and is pretty much the only way to ensure you get almost all of the traffic.
The second is to create browser specific add-on. IE calls it a Browser Helper Object (BHO), I think Firefox just calls it a "Browser Extension", etc. You will have to build a separate one for each browser (IE/FF/Chrome) you want to cover. Google those terms to see how to get started. Beware that doing so is quite complicated and will require you to jump through a lot of hoops for security reasons.
This article is a bit old (2010) but should give you enough information to at least know what you are about to get yourself into: https://msmvps.com/blogs/vcsjones/archive/2010/05/23/writing-a-managed-internet-explorer-extension-part-1.aspx

Load-testing a web application

How does one go about testing the server-side performance of a web application?
I'm working on a small web application (specifically, it will solely be responding to AJAX requests with database rows). I want to see how it performs under load. However, I cannot upload it to an internet host right away. The development environment is, however, part of the local intranet, so I can use as many machines as I want to hammer the development server, presumably using Python in conjunction with urllib2.
My question is, is such an approach really accurate for determining the high-load performance of a server-side script? Is there a better way to do this? Am I missing something here?
Have you tried a tool like Apache JMeter? http://jmeter.apache.org/

Best whitelist capable http proxy for Windows?

I would like to setup a http proxy on my work machine (no admin rights, WinXP) to only allow access to a whitelist of URLs. What would be the easiest solution? I prefer open-source software if possible.
Squid seems to be the de facto proxy. This link describes how to set it up on a windows box: http://www.ausgamers.com/features/read/2638752
Why not use the Content Advisor in IE? You can provide a list of approved sites, anything else is blocked. Or do you want pass-through functionality like a true proxy?
Content advisor will ask for authorization every time a javascript function is called. At least that's my experience right now, and that's how I landed here, after hours of googling.
You are right, however, if the sites in the whitelist don't use javascript intensively and I would suggest that that option be tried first because (and I'm an IT person), it's FAAAAAAAAR easier to set up Content Advisor than a proxy server. Google "noaccess.rat" and you'll come accross articles that tell you how to set up IE using a white-list approach.
Having said this, however, you must be fully aware that Content Advisor can be easily disabled, even without knowing the password. One of my users did it in no time. You can find this in google as well.
Alex

Firefox plugin - sockets

I've always wanted a way to make a socket connection to a server and allow the server to manipulate the page DOM. For example, this could be used in a stock quotes page, so the server can push new quotes as they become available.
I know this is a classic limitation (feature?) of HTTP's request/response protocol, but I think this could be implemented as a Firefox plugin (cross-browser compatibility is not important for my application). Java/Flash solutions are not acceptable, because (as far as i know) they live in a box and can't interact with the DOM.
Can anyone confirm whether this is within the ability of a Firefox plugin? Has someone already created this or something similar?
You may want to look at Comet which is a fancy name for a long running HTTP connection where the server can push updates to the page.
It should be possible. I have developed a xulrunner application that connects to a TCP server using sockets. Extension development would likely have the same capabilities. I used a library from mozdev - JSLib. Specifically check out the networking code. The fact that there is a Firefox add-on for JSlib add-on for Firefox makes more more confident.
Essentially, as I understand it, sockets are not part of JavaScript, but through XPCOM, you can get raw socket access like you would in any c/c++ application.
Warning: JSLib doesn't seem to receive a lot of attention and the mailing list is pretty sparse.
Java/Flash solutions are not acceptable, because (as far as i know)
they live in a box and can't interact with the DOM.
That's not actually true of Java. You can interact with Java via JavaScript and make DOM changes.
http://stephengware.com/proj/javasocketbridge/
In this example there are two JavaScript methods for interaction
Send:
socket_send("This was sent via the socket\n\n");
Receive:
on_socket_get(message){ more_code(message); }
You may want to look at Comet
a.k.a. server push. This does not let the server "update" the client page directly, but all the new data is sent to the page through a single connection.
Of course, a Firefox extension (as well as plugins, which are binary libraries that can do whatever any other application can do) can work with sockets too. See 1, 2.

Resources