473,545 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6017
On Aug 23, 6:13 am, FrobinRobin <frobinro...@ho tmail.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.comwrot e:
On Aug 23, 6:13 am, FrobinRobin <frobinro...@ho tmail.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.comwrot e:
>On Aug 23, 6:13 am, FrobinRobin <frobinro...@ho tmail.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*******@attgl obal.net
=============== ===
Aug 23 '07 #4
On Aug 23, 9:54 am, FrobinRobin <frobinro...@ho tmail.comwrote:
On 23 Aug, 15:37, "burgermeiste.. .@gmail.com"

<burgermeiste.. .@gmail.comwrot e:
On Aug 23, 6:13 am, FrobinRobin <frobinro...@ho tmail.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...@ho tmail.comwrote:
On 23 Aug, 15:37, "burgermeiste.. .@gmail.com"

<burgermeiste.. .@gmail.comwrot e:
On Aug 23, 6:13 am, FrobinRobin <frobinro...@ho tmail.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*******@attgl obal.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
6039
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 as a module. Thanks. -- -- Rudy Fleminger -- sp@mmers.and.evil.ones.will.bow-down-to.us (put "Hey!" in the Subject line for priority...
4
2694
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? Should I write something into the app that can do this... if so, are there any useful libraries for this purpose? Or, should I maybe look into using a...
3
1770
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
1069
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 info, including non ASP.NET pages (HTML, PHP, etc)? Thanks, Brett
0
1038
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 etc. Whenever a user performs any such action, I did like to find out the bandwidth used in the process. Is it possible to find out the bandwidth...
1
4460
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 they begin (body onlLoad="startshow.js") But it seems entirely possible to combine asynchronous ajax requests with php session variables, so a...
3
2330
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, then the onClick function of this particular link is not working. Plz help
2
2904
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 to the Star rating at the bottom of search product) http://cameras.pricegrabber.com/digital/camera/p/48/form_keyword=camera/rd=1 Please let me...
0
915
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 the amount of data the user dowloads. My current application allows for browsing provided the customer's time slot is not exhuasted Kindly...
0
7685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7941
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7452
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6014
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3485
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.