473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calculating page bandwidth usage (PHP/Ajax)

Hi,

I intend to use Ajax for a kiosk application, it's primary usage is to
retrieve live data from my DB, it's a fairly small amount of data (5
fields, of small data size and limited to 15 rows).

When I check my server logs I can see that the kiosk page has used a
fair amount of bandwidth this month, this is obviously because a
javascript timeout refreshes the data every 10 seconds. What I need to
know is how to calculate the bandwidth of the data for every ten
seconds and then I can do the math to work out usage hours * bandwidth
per hour.

This is probably a fairly simple task but I've never done it before so
any help would be much appreciated!

Many Thanks

Aug 23 '07 #1
8 6007
On Aug 23, 6:13 am, FrobinRobin <frobinro...@hotmail.comwrote:
Hi,

I intend to use Ajax for a kiosk application, it's primary usage is to
retrieve live data from my DB, it's a fairly small amount of data (5
fields, of small data size and limited to 15 rows).

When I check my server logs I can see that the kiosk page has used a
fair amount of bandwidth this month, this is obviously because a
javascript timeout refreshes the data every 10 seconds. What I need to
know is how to calculate the bandwidth of the data for every ten
seconds and then I can do the math to work out usage hours * bandwidth
per hour.

This is probably a fairly simple task but I've never done it before so
any help would be much appreciated!

Many Thanks
I'm not entirely sure that PHP is really the best solution to your
problem. There may be a method of measuring bandwidth with PHP, but
probably an easier way would simply be to use a network analyzer, for
example, Ethereal. However, such software has little to do with PHP
programming, so unless you still feel that PHP is the best solution,
further inquiries should be directed to a more fitting newsgroups.

Good luck!

Aug 23 '07 #2
On 23 Aug, 15:37, "burgermeiste...@gmail.com"
<burgermeiste...@gmail.comwrote:
On Aug 23, 6:13 am, FrobinRobin <frobinro...@hotmail.comwrote:


Hi,
I intend to use Ajax for a kiosk application, it's primary usage is to
retrieve live data from my DB, it's a fairly small amount of data (5
fields, of small data size and limited to 15 rows).
When I check my server logs I can see that the kiosk page has used a
fair amount of bandwidth this month, this is obviously because a
javascript timeout refreshes the data every 10 seconds. What I need to
know is how to calculate the bandwidth of the data for every ten
seconds and then I can do the math to work out usage hours * bandwidth
per hour.
This is probably a fairly simple task but I've never done it before so
any help would be much appreciated!
Many Thanks

I'm not entirely sure that PHP is really the best solution to your
problem. There may be a method of measuring bandwidth with PHP, but
probably an easier way would simply be to use a network analyzer, for
example, Ethereal. However, such software has little to do with PHP
programming, so unless you still feel that PHP is the best solution,
further inquiries should be directed to a more fitting newsgroups.

Good luck!- Hide quoted text -

- Show quoted text -
I just want to know how much data each ajax request is - I dont want
to start messing around with third party apps.
How about if I outputted the data to a file then used the filesize()
function? Would that give me the correct data size per ajax request?

Aug 23 '07 #3
FrobinRobin wrote:
On 23 Aug, 15:37, "burgermeiste...@gmail.com"
<burgermeiste...@gmail.comwrote:
>On Aug 23, 6:13 am, FrobinRobin <frobinro...@hotmail.comwrote:


>>Hi,
I intend to use Ajax for a kiosk application, it's primary usage is to
retrieve live data from my DB, it's a fairly small amount of data (5
fields, of small data size and limited to 15 rows).
When I check my server logs I can see that the kiosk page has used a
fair amount of bandwidth this month, this is obviously because a
javascript timeout refreshes the data every 10 seconds. What I need to
know is how to calculate the bandwidth of the data for every ten
seconds and then I can do the math to work out usage hours * bandwidth
per hour.
This is probably a fairly simple task but I've never done it before so
any help would be much appreciated!
Many Thanks
I'm not entirely sure that PHP is really the best solution to your
problem. There may be a method of measuring bandwidth with PHP, but
probably an easier way would simply be to use a network analyzer, for
example, Ethereal. However, such software has little to do with PHP
programming, so unless you still feel that PHP is the best solution,
further inquiries should be directed to a more fitting newsgroups.

Good luck!- Hide quoted text -

- Show quoted text -

I just want to know how much data each ajax request is - I dont want
to start messing around with third party apps.
How about if I outputted the data to a file then used the filesize()
function? Would that give me the correct data size per ajax request?
For text, but not necessarily for the images.

But then polling like you're doing is a very poor practice, anyway. It
puts unnecessary load on the client, server and network.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 23 '07 #4
On Aug 23, 9:54 am, FrobinRobin <frobinro...@hotmail.comwrote:
On 23 Aug, 15:37, "burgermeiste...@gmail.com"

<burgermeiste...@gmail.comwrote:
On Aug 23, 6:13 am, FrobinRobin <frobinro...@hotmail.comwrote:
Hi,
I intend to use Ajax for a kiosk application, it's primary usage is to
retrieve live data from my DB, it's a fairly small amount of data (5
fields, of small data size and limited to 15 rows).
When I check my server logs I can see that the kiosk page has used a
fair amount of bandwidth this month, this is obviously because a
javascript timeout refreshes the data every 10 seconds. What I need to
know is how to calculate the bandwidth of the data for every ten
seconds and then I can do the math to work out usage hours * bandwidth
per hour.
This is probably a fairly simple task but I've never done it before so
any help would be much appreciated!
Many Thanks
I'm not entirely sure that PHP is really the best solution to your
problem. There may be a method of measuring bandwidth with PHP, but
probably an easier way would simply be to use a network analyzer, for
example, Ethereal. However, such software has little to do with PHP
programming, so unless you still feel that PHP is the best solution,
further inquiries should be directed to a more fitting newsgroups.
Good luck!- Hide quoted text -
- Show quoted text -

I just want to know how much data each ajax request is - I dont want
to start messing around with third party apps.
How about if I outputted the data to a file then used the filesize()
function? Would that give me the correct data size per ajax request?
FrobinRobin,

I looked into your situation a little more, and as far as I can see,
directly, with PHP, there is no clear way to measure bandwidth usage.
However, something I overlooked, apache typically keeps an access_log
file which records all requests and the size of the data transferred
in requests. If you're using apache as your web server, reading from
that file is one possible solution. Other web servers may have similar
logs. I'm not sure if the file records the size of the headers sent
though, which is the same concern I have with what you purposed as a
solution, as well as what Jerry mentioned about binaries.

Aug 23 '07 #5
On Aug 23, 9:54 am, FrobinRobin <frobinro...@hotmail.comwrote:
On 23 Aug, 15:37, "burgermeiste...@gmail.com"

<burgermeiste...@gmail.comwrote:
On Aug 23, 6:13 am, FrobinRobin <frobinro...@hotmail.comwrote:
Hi,
I intend to use Ajax for a kiosk application, it's primary usage is to
retrieve live data from my DB, it's a fairly small amount of data (5
fields, of small data size and limited to 15 rows).
When I check my server logs I can see that the kiosk page has used a
fair amount of bandwidth this month, this is obviously because a
javascript timeout refreshes the data every 10 seconds. What I need to
know is how to calculate the bandwidth of the data for every ten
seconds and then I can do the math to work out usage hours * bandwidth
per hour.
This is probably a fairly simple task but I've never done it before so
any help would be much appreciated!
Many Thanks
I'm not entirely sure that PHP is really the best solution to your
problem. There may be a method of measuring bandwidth with PHP, but
probably an easier way would simply be to use a network analyzer, for
example, Ethereal. However, such software has little to do with PHP
programming, so unless you still feel that PHP is the best solution,
further inquiries should be directed to a more fitting newsgroups.
Good luck!- Hide quoted text -
- Show quoted text -

I just want to know how much data each ajax request is - I dont want
to start messing around with third party apps.
How about if I outputted the data to a file then used the filesize()
function? Would that give me the correct data size per ajax request?
Oh, and one other thing, just for the record, Ethereal is free and
relatively easy to use, so I can't say I entirely understand your
reluctance to try it.

Aug 23 '07 #6
ok, thanks for the responses.

In reply to burgermeister01 I've already checked the server logs and
they give me the bandwidth overview of file requests; not just the
Ajax part which I want. I fear this is the same info Ethereal will
give me plus I do not want to waste time with a new app.. so I prefer
not to get involved with it; but thanks for the help, it is certainly
noted for future reference.

I've calculated an average 10kb for each ajax request using the
filesize function, polling every ten seconds equates to 1KB/s, which
doesnt seem that bad. However, this application will serve a few
hundred kiosks so even 1KB/s is a lot.

I appreciate what Jerry is saying about load on client, server and
network and all of the Ajax calls that are getting the same data is a
really bad waste (damn ur always right Jerry!). Maybe if I changed the
script to compare the local client data against the server data using
a DB SELECT and then download only the changes? This would at least
limit some wasted bandwidth. (Your comments Jerry are always
appreciated)

I know this is all about the way the http protocol works, hence why I
introduced Ajax, apart from the wastage it seemed like the right
idea.
So maybe a server process (which I've heard of but have no real PHP
integration experience with) that would monitor the DB and prompt? the
client to update? Considering I have full control over the kiosk I
could even connect directly to it and maybe use files (xml maybe)
instead of a database? Seems as its only 10-15 records with five small
fields in it?

Any pointers in the right direction would be very appreciated.

Aug 23 '07 #7
FrobinRobin wrote:
ok, thanks for the responses.

In reply to burgermeister01 I've already checked the server logs and
they give me the bandwidth overview of file requests; not just the
Ajax part which I want. I fear this is the same info Ethereal will
give me plus I do not want to waste time with a new app.. so I prefer
not to get involved with it; but thanks for the help, it is certainly
noted for future reference.

I've calculated an average 10kb for each ajax request using the
filesize function, polling every ten seconds equates to 1KB/s, which
doesnt seem that bad. However, this application will serve a few
hundred kiosks so even 1KB/s is a lot.

I appreciate what Jerry is saying about load on client, server and
network and all of the Ajax calls that are getting the same data is a
really bad waste (damn ur always right Jerry!). Maybe if I changed the
script to compare the local client data against the server data using
a DB SELECT and then download only the changes? This would at least
limit some wasted bandwidth. (Your comments Jerry are always
appreciated)

I know this is all about the way the http protocol works, hence why I
introduced Ajax, apart from the wastage it seemed like the right
idea.
So maybe a server process (which I've heard of but have no real PHP
integration experience with) that would monitor the DB and prompt? the
client to update? Considering I have full control over the kiosk I
could even connect directly to it and maybe use files (xml maybe)
instead of a database? Seems as its only 10-15 records with five small
fields in it?

Any pointers in the right direction would be very appreciated.
Well, you could use Ajax to poll a special page which returns just "y"
or "n", as to whether something has changed. Pass a unique id for the
kiosk and let the server determine if something has changed. If it has,
Ajax can return a new page.

More server side processing, but even with the header info going back
and forth, total traffic should be much less.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 24 '07 #8
FrobinRobin wrote:
I fear this is the same info Ethereal will give me plus I do not want to
waste time with a new app.
Really Ethereal (which is actually called "Wireshark" now -- it was
renamed over a year ago) will give you exactly the information you need:
the exact number of bytes being transmitted, including not just the data
and HTTP headers, but also the overhead added by TCP/IP.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 64 days, 12:07.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/0...ivial-encoder/
Aug 24 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: FLEB | last post by:
Is there a way to check my site's bandwidth usage via PHP? I'd like to "gracefully bail" if I start to get near my host's limit. Its running on a shared Linux box, on Apache 1.3.31 and PHP v4.3.3...
4
by: Marcus | last post by:
I have a program that I wrote that connects to a remote server and recieves data at random intervals. I'd like to measure the bandwidth usage of this program. What is the best way to do this?...
3
by: Raj | last post by:
is it possible using C# dotnet to control the bandwidth usage means the transfer rate of download and upload? Thanks!
0
by: brett | last post by:
My shared hosting service provides statistics on bandwidth usage once/mo. I need to track bytes transferred on a daily basis. Is there something I can do in ASP.NET 2.0 for getting bandwidth...
0
by: rn5a | last post by:
In a ASP.NET application, users can upload files from their hard disk to the server. Users can also create new files & directories directly on the server, rename them, delete them, edit the files...
1
by: sandy | last post by:
javascript slide shows can be a useful, quick and dirty way to display a small collection of images. But javascript slide shows typically want to download a whole directory full of images before...
3
by: msinghal | last post by:
hi, I am facing one problem which is related to AJAX. I have a html page which has some links. When the page is refreshed using AJAX then if some new new link is added to the page on this refresh,...
2
rahulephp
by: rahulephp | last post by:
I am looking for the PHP Ajax mouse move popup box. It should show a small cool looking popup window when i move mouse on "Seller" link. I saw this thing here: Move the mouse on "Sellers" (next...
0
by: topspino | last post by:
Hi, Very new to this forum and would be glad to make some new friend's. Would appreciate anybody's help with a VB.net Code that can bill my internet cafe customers based upon bandwidth usage or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.