This is my node code
var http = require('http');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password: '########'
});
connection.connect(function (err){
if(err){
console.log('error!!!'+err.stack);
return;
}
console.log('connected..');
});
http.createServer(function (req, res) {
connection.query('use test');
var strQuery = 'select * from prod_master';
connection.query( strQuery, function(err, rows){
if(err) {
throw err;
}else{
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(JSON.stringify(rows));
}
});
}).listen(9615);
========================PHP Code===========================
<?php
mysql_connect("localhost","root","#########");
mysql_select_db("test");
$result=mysql_query("select * from prod_master");
$row = array();
while($r=mysql_fetch_assoc($result))
{
$row[] = $r;
}
echo json_encode($row);
?>
On Wednesday, February 18, 2015 at 3:50:19 PM UTC-6, Aria Stewart wrote:
>
>
> On Feb 18, 2015, at 1:34 PM, Anirban Bhattacharya <
> [email protected] <javascript:>> wrote:
>
> Hi,
> I am new to node. very new ..like infant.
> Either I am doing something wrong or I understood everything wrong.
> I wrote a node js simple JSON emitter which uses mysql module and query
> (select *) from a single table haviing 100 records and outputs on page as
> JSON (JSON.stringify..
>
> I wrote a PHP page which also does the same thing from same table(Apache).
>
>
>
> It looks like node is transferring a lot more data- - sounds like this is
> not an apples to apples comparison.
>
> What kind of concurrency do you have on talking to mySQL?
>
> Actual scripts would be easier to compare. Without seeing what you've
> written, it's hard to say why what's faster is faster.
>
> Aria
>
>
>
> I used Siege for load test and surprisingly it shows better values for the
> PHP than that of node .. see below the output of siege
> ==================NODE=================
> anirbanb2004@Anisoft-Corporation:~$ siege -c100 -d1 -t10M -lnode.log
> http://localhost:9615/
> ** SIEGE 3.0.5
> ** Preparing 100 concurrent users for battle.
> The server is now under siege...
> Lifting the server siege... done.
>
> Transactions: 119236 hits
> Availability: 100.00 %
> Elapsed time: 599.74 secs
> Data transferred: 403.00 MB
> Response time: 0.00 secs
> Transaction rate: 198.81 trans/sec
> Throughput: 0.67 MB/sec
> Concurrency: 0.61
> Successful transactions: 119236
> Failed transactions: 0
> Longest transaction: 0.05
> Shortest transaction: 0.00
>
> FILE: node.log
> =================PHP==================
> anirbanb2004@Anisoft-Corporation:~$ siege -c100 -d1 -t10M -lphp.log
> http://localhost/loadTest
> ** SIEGE 3.0.5
> ** Preparing 100 concurrent users for battle.
> The server is now under siege...
> Lifting the server siege... done.
>
> Transactions: 119632 hits
> Availability: 100.00 %
> Elapsed time: 599.47 secs
> Data transferred: 34.58 MB
> Response time: 0.00 secs
> Transaction rate: 199.56 trans/sec
> Throughput: 0.06 MB/sec
> Concurrency: 0.12
> Successful transactions: 59858
> Failed transactions: 0
> Longest transaction: 0.03
> Shortest transaction: 0.00
>
> FILE: php.log
>
> can anyone please help me understand what is wrong here? I understand some
> scenario will be there where PHP will perform better. What scenario should
> I create to test Node is better?
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/b4db83d5-7fe9-4c5e-b87c-9c7c852a0e33%40googlegroups.com
>
> <https://groups.google.com/d/msgid/nodejs/b4db83d5-7fe9-4c5e-b87c-9c7c852a0e33%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
On Wednesday, February 18, 2015 at 3:50:19 PM UTC-6, Aria Stewart wrote:
>
>
> On Feb 18, 2015, at 1:34 PM, Anirban Bhattacharya <
> [email protected] <javascript:>> wrote:
>
> Hi,
> I am new to node. very new ..like infant.
> Either I am doing something wrong or I understood everything wrong.
> I wrote a node js simple JSON emitter which uses mysql module and query
> (select *) from a single table haviing 100 records and outputs on page as
> JSON (JSON.stringify..
>
> I wrote a PHP page which also does the same thing from same table(Apache).
>
>
>
> It looks like node is transferring a lot more data- - sounds like this is
> not an apples to apples comparison.
>
> What kind of concurrency do you have on talking to mySQL?
>
> Actual scripts would be easier to compare. Without seeing what you've
> written, it's hard to say why what's faster is faster.
>
> Aria
>
>
>
> I used Siege for load test and surprisingly it shows better values for the
> PHP than that of node .. see below the output of siege
> ==================NODE=================
> anirbanb2004@Anisoft-Corporation:~$ siege -c100 -d1 -t10M -lnode.log
> http://localhost:9615/
> ** SIEGE 3.0.5
> ** Preparing 100 concurrent users for battle.
> The server is now under siege...
> Lifting the server siege... done.
>
> Transactions: 119236 hits
> Availability: 100.00 %
> Elapsed time: 599.74 secs
> Data transferred: 403.00 MB
> Response time: 0.00 secs
> Transaction rate: 198.81 trans/sec
> Throughput: 0.67 MB/sec
> Concurrency: 0.61
> Successful transactions: 119236
> Failed transactions: 0
> Longest transaction: 0.05
> Shortest transaction: 0.00
>
> FILE: node.log
> =================PHP==================
> anirbanb2004@Anisoft-Corporation:~$ siege -c100 -d1 -t10M -lphp.log
> http://localhost/loadTest
> ** SIEGE 3.0.5
> ** Preparing 100 concurrent users for battle.
> The server is now under siege...
> Lifting the server siege... done.
>
> Transactions: 119632 hits
> Availability: 100.00 %
> Elapsed time: 599.47 secs
> Data transferred: 34.58 MB
> Response time: 0.00 secs
> Transaction rate: 199.56 trans/sec
> Throughput: 0.06 MB/sec
> Concurrency: 0.12
> Successful transactions: 59858
> Failed transactions: 0
> Longest transaction: 0.03
> Shortest transaction: 0.00
>
> FILE: php.log
>
> can anyone please help me understand what is wrong here? I understand some
> scenario will be there where PHP will perform better. What scenario should
> I create to test Node is better?
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/b4db83d5-7fe9-4c5e-b87c-9c7c852a0e33%40googlegroups.com
>
> <https://groups.google.com/d/msgid/nodejs/b4db83d5-7fe9-4c5e-b87c-9c7c852a0e33%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/be2cc337-3c48-4b93-8d2e-691c5fbadc6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.