LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   could you please give me some instructions of my experiment? (http://www.linuxquestions.org/questions/linux-server-73/could-you-please-give-me-some-instructions-of-my-experiment-827370/)

koshihaku 08-20-2010 01:28 AM

could you please give me some instructions of my experiment?
 
I am a student and I am doing a experiment for my graduation thesis.

I use two computers, one as server (ubuntu apache), and one as client. On the client, I use httperf and autobench to benchmark the apache server. I want to get the real-time memory used by apache server and analysis them.

Now I have a PROBLEM:
I need to used dynamic content in the requests. I was told that the generation of dynamic content can be achieved through a program built to simulate database accesses and to create HTML pages according to the sizes defined previously e.g. 100kb, 1Mb or 2Mb.

But I am a newbie lack of knowledge of this. Could anybody give my any advices or instruction about this?

How can I achieve this using httperf and autobench?

I am sorry for innocent questions. Thank you very much!

carltm 08-20-2010 07:21 AM

If you need to generate dynamic content, the easiest way would be to
install php. With php you can embed code inside html files which will
run every time the pages are opened.

koshihaku 08-20-2010 11:44 AM

Quote:

Originally Posted by carltm (Post 4072256)
If you need to generate dynamic content, the easiest way would be to
install php. With php you can embed code inside html files which will
run every time the pages are opened.


Thank you very much!

If I made a html page for example /var/www/html/test.html, do you mean I can make a php code inside the "test.html", and when I do test, I need to send request of "test.html" on the client-side?

And if I make several html pages with different size, I can achieve my requirement?

I have no knowledge of php, is that ok for me to study from zero? If I just learn some basic knowledge, is that enough for this?

Thanks!

frieza 08-20-2010 12:39 PM

Quote:

Originally Posted by koshihaku (Post 4072507)
And if I make several html pages with different size, I can achieve my requirement?

that would not qualify as 'dynamic', actually if i were an instructor would probably mark that a fail

Quote:

Originally Posted by koshihaku (Post 4072507)
If I made a html page for example /var/www/html/test.html, do you mean I can make a php code inside the "test.html", and when I do test, I need to send request of "test.html" on the client-side?

it would be 'test.php' unless you linke the php script in an iframe in 'test.html' or modify the server to execute html documents with the php parser

Quote:

Originally Posted by koshihaku (Post 4072507)
I have no knowledge of php, is that ok for me to study from zero? If I just learn some basic knowledge, is that enough for this?

that would be up to the instructor but the whole point of getting a degree is learning so i would probably say that is acceptable, you can learn alot from php's website for instance
http://us.php.net/manual/en/function.fgetcsv.php

Quote:

Originally Posted by koshihaku (Post 4072507)
I need to used dynamic content in the requests. I was told that the generation of dynamic content can be achieved through a program built to simulate database accesses and to create HTML pages according to the sizes defined previously e.g. 100kb, 1Mb or 2Mb.

best way i can think of to simulate database access is with a csv file, (csv files can be created in just about any major spreadsheet program like excell or openoffice.org calc) the above link to php.net should be a starting point on how to parse csv files

i would say to focus on at least a bare minimum the following:

- opening a CSV file for reading/writing (csv as stated is a decent stand in for a database table and can be created easily with a spreadsheet program)

-basic array structure

-a few basic loops (particularly while and foreach to recurse through the rows/columns of a csv file respectively)

-working with superglobals (eg $_GET and $_POST)


the simplest example would be to create an index.php that uses $_GET to specify which 'table' (csv file) to use and generate a simple html <table> structure eg
Code:

http://server/?table=100kb
in the above example 'index.php' is assumed so it would be the equivilent of
Code:

http://server/index.php?table=100kb
would output the contents of 100kb.csv in simple table format

possibly learn the basics how to make http requests with javascript (AJAX)

hope this helps a bit, good luck

frieza 08-20-2010 05:49 PM

p.s. you could also use a simple for next loop to generate X number random characters (8 bits per char) based on a number of K bytes input
like
Code:

http://server/?kbytes=100
which would be something like
Code:

<?php
for ($x=1;$x<=(($_GET['kbytes'])*1024)/8);$x++) {
    echo ("b");
}
?>

if course that wouldnt be very impressive and probably not adaquate

koshihaku 08-23-2010 09:49 AM

Quote:

Originally Posted by frieza (Post 4072780)
p.s. you could also use a simple for next loop to generate X number random characters (8 bits per char) based on a number of K bytes input
like
Code:

http://server/?kbytes=100
which would be something like
Code:

<?php
for ($x=1;$x<=(($_GET['kbytes'])*1024)/8);$x++) {
    echo ("b");
}
?>

if course that wouldnt be very impressive and probably not adaquate



Thank you very much!

Do you mean I need to open a csv file with a certain size? If I write that to the php script, does that mean everytime I send request to server, it will generate a csv file with the certain size?

frieza 09-03-2010 12:41 PM

the script that you quoted simply generates X kb of the letter b

otherwise yes opening a csv of a certain size and parsing it to a table such as
Code:

<?php
$file=fopen("/path/to/".$_GET['file'].".csv",r);
$output="<table>";
while ($row=fgetcsv($file)) {
    $output.="<tr>";
    foreach($row as $col) {
        $output.="<td>".$col."</td>";
    }
    $output.="</tr>";
}
$output.="</table>";
fclose($file);
echo $output;

when saved as index.php and accessed as
Code:

http://host/?file={filename} (minus the .csv extension and path, is assumed by the program)
should output an html table containing the csv data
the csv files should be created using a spreadsheet and put in a directory readable by your script
hopefully this clear up your confusion


All times are GMT -5. The time now is 07:20 PM.