|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
Minimum bandwidth for a HTTP request
I wonder how to minimize the bandwidth on a HTTP request.
The situation is this: I have an application that intermittently requests a page from the server containing only javascript variables. Most of the time, the page contains no new information, and so a blank page is sent. The application requests the page every ten seconds or less, and there can be up to two hundred of them running at once. Obviously, this adds up to gigabytes per day. I don't have the bandwidth, and even if I did, it reduces performance dramatically. I want to minimize the size of the file that is sent unless there is actually something to send. I have a number of ideas for this. I just don't have a clear idea of which is the most effective, or if there is an altogether different better way. 1. use the exit(); function in PHP before any headers or content is sent. In this case, viewing the source of the page gives: Quote:
2. Don't echo any content (in this case view source shows the same as above) 3. <?echo " ";?>, I assume normal headers are sent. how can I tell what the total size of the transfer is? 4. Set the headers to the smallest possible size (so what would this be?) 5. Is it possible to intentionally ignore a HTTP request? Thanks for any thoughts... P |
|
#2
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Just so I understand, from the webpage you only want to get the javascript and not any of the HTML?
Or may I further ask what does this thing do |
|
#3
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
aha! curious I see...
I'll give you three guesses ;) Hint: it's a page that loads periodically in a hidden frame, and I am passing data (when it's available) to the client via JavaScript variables (for lack of a better way)... When there are no variables to get, I want to send nothing at all (if possible). |
|
#4
|
||||
|
||||
|
RE: Minimum bandwidth for a HTTP request
Are you sure you're not already sending nothing? If there is no output, there is no output; your webserver shouldn't just be sending a default HTML page in place of nothing. The HTML you're seeing could just be what your browser is displaying when you view the source of an empty page. Try checking your logs to see how big the file you're returning is.
|
|
#5
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
I don't know Mugane, sound like your up to no good
Does the java have to be in the HTML page or could you use pear or just open a socket and grab from a text file or something like that? Well that won't work because it has to be client side huh? Hmm. I'm thinking aloud |
|
#6
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
yeah, Paul you're getting warm ;)
It's true, I'm looking at a blank page. It's a small, blank page (2.5kb?), but it gets loaded about 9000 times each day - about 600Mb per month from that file alone. And that's just one instance of the application. Ideally I would like to have a couple of hundred of these little twits running around, so yeah, ~120Gigs per month... Two guesses left... |
|
#7
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Is this in one of your servers. Why not run a sniffer and see what is really being sent.
I can't see you making it much smaller than that. Drop me an email I am intrigued |
|
#8
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
a sniffer, eh? what's that? I want one of those...
|
|
#9
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Ahh, My Friend http://www.ethereal.com/ It's a beautiful thing. Just make sure that the box you have it on is on a switch not a hub or you will be grabbing all traffic.
|
|
#10
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Well, each time a request is made, I'd say at least 1k is spent on headers..
What you could do is to wait until there is some data to send... Like BUT, when you'll have 200 clients, you'll also have 200 Apache processes in memory doing nothing, but still wasting memory, which is also not very good. HTTP is not a very good protocol for such things, I'm afraid... |
|
#11
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Thanks xs0!
Well, I would take 200 processes over 200 gigs of bandwidth... but, I foresee a problem with waiting - I think that there may actually be a lot more like 1000+ processes - after all, the page will be refreshed every 10 seconds, and a new process will be started for each refresh... also, even if I waited, I would still have to send something for each process that was started, and the result would be the same, only delayed (unless I could somehow end the process without sending anything - I wish I knew a way). This would be averted if I could force a refresh from the server side. This does not seem likely - but is it possible? |
|
#12
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Well, a stupid way would be to make a PHP function that would crash the Apache process, so no output would be sent, but you'd still get input... Some ISPs only count output traffic, though, so ... ;)
The result wouldn't be the same only delayed - there would be far fewer requests, because a refresh would happen only every (e.g.) 50 seconds, instead of 10, but it could still happen after 10 seconds, if there was something new to refresh to... But like I said, HTTP is a bad protocol for this kind of thing anyway, so you may want to consider something else... |
|
#13
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
everything xs0 said, and two more things.
1) you are building a serverside chat. http is not very good protocol for that. consider java, or something else that can receive a server push instead of pulling every 10 seconds.. 2) that html you see in your browser if you don't echo anything is just dummy html. it is not sent. your browser only shows it.. and if you want to see exactly what is sent, no need for snifer. if you use mozilla of firebird, look for LiveHTTPHeaders extension. a must have for web programmers... |
|
#14
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
Good guess! although I was curious to see what else you would come up with... Thanks for the info, by the way.
Java is horrendous, there's no way I would ever remotely consider using it. It just plain sucks. "I would rather use Java than Perl. And I'd rather be eaten by a crocodile than use Java." — Trouser. My objective, rather, is to design the system so that users do not have to download anything or install any plug-in nonesense. Sure, http is not ideal, but it's what everyone is guaranteed to have... Yes, on second thought I do see what you mean about the processes, but this is contingent upon the client not refreshing intermittently, but rather waiting for a correct response - which should be possible. This is probably how I will end up doing it, but there is also the problem of maximum execution time... 30 seconds. Do you know if it is possible to change this using .htaccess or by transferring control to another process? I have not heard of being able to change php.ini settings at run-time... I'll definitely look into the LiveHTTPHeaders extension, thanks for the tip! PS. What's a good way to crash the server process? Hee hee hee... |
|
#15
|
|||
|
|||
|
RE: Minimum bandwidth for a HTTP request
I've seen a serverside chat system written in perl (i think...)
it had a page in an iframe that never finished loading (with the chat window) in it, so the text appeared pritty much realtime.... of course, i only saw this over the shoulder of someone else, and it was wen i didnt understand about these things ;) - Craig |