Tag Archives: apache

Why serving files with nodejs is faster than apache when I use a single mongodb connection? [closed]

Salam (means Hello) :)

I'm trying to improve speed of my nodejs website which depends on some mongodb operations and serving some static files. I'm using node-mongodb-native driver. as far as I know:

  1. Nodejs is slow on serving static files, nginx or apache are better options for this task.
  2. Caching a single db object and using it during application run time, is faster than calling MongoClient.connect() for every database operation.

nginx is not currently an option for me. So using a single db connection along side using apache for static files should be fastest combination, but tests on a semi-production environment don't verify this theory:

file server / db connection : speed  

nodejs / multiple : 24895ms
apache / multiple : 10770ms

nodejs / single   :  7068ms
apache / single   : 14995ms

So why when using multiple connections, apache makes my application load faster, and when using a single connection, apache makes my application load slower?

How to submit a POST request to Apache Syncope API in node.js?

Salam (means Hello) :)

In my node.js application, I am trying to add a user to Apache Syncope via its RESTful API. Apache Syncope is installed on a remote VPS and this article demonstrate this process in a PHP environment. here is what I did in my node.js application:

http.createServer(onRequest).listen(80);

function onRequest (request, response) {
    var options = {
        hostname: MY_VPS_IP,
        port: 8080,
        path: '/syncope/rest/user/create.json',
        auth: 'admin:password',
        method: 'POST'
    };
    var data = {an: 'object', of: 'new', user: 'data' };

    var req=http.request(options, function(res) {
        var body;
        res.on('data', function (chunk) {
            body += chunk;
        });
        res.on('end', function () {
            response.writeHead(200, { 'Content-Type': 'text/html' });
            response.end(body, 'utf-8');
        });
    });
    req.end(JSON.stringify(data));
}

The response of Apache Syncope is a 415 error (css styles omitted):

undefined
<html>
<head><title>Apache Tomcat/7.0.42 - Error report</title>
</head>
<body><h1>HTTP Status 415 - </h1>
<HR size="1" noshade="noshade">
<p><b>type</b> Status report</p>

<p><b>message</b> <u></u></p>

<p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by the
    requested resource for the requested method.</u></p>
<HR size="1" noshade="noshade">
<h3>Apache Tomcat/7.0.42</h3></body>
</html>

How to submit a POST request to Apache Syncope API in node.js?

Salam (means Hello) :)

In my node.js application, I am trying to add a user to Apache Syncope via its RESTful API. Apache Syncope is installed on a remote VPS and this article demonstrate this process in a PHP environment. here is what I did in my node.js application:

http.createServer(onRequest).listen(80);

function onRequest (request, response) {
    var options = {
        hostname: MY_VPS_IP,
        port: 8080,
        path: '/syncope/rest/user/create.json',
        auth: 'admin:password',
        method: 'POST'
    };
    var data = {an: 'object', of: 'new', user: 'data' };

    var req=http.request(options, function(res) {
        var body;
        res.on('data', function (chunk) {
            body += chunk;
        });
        res.on('end', function () {
            response.writeHead(200, { 'Content-Type': 'text/html' });
            response.end(body, 'utf-8');
        });
    });
    req.end(JSON.stringify(data));
}

The response of Apache Syncope is a 415 error (css styles omitted):

undefined
<html>
<head><title>Apache Tomcat/7.0.42 - Error report</title>
</head>
<body><h1>HTTP Status 415 - </h1>
<HR size="1" noshade="noshade">
<p><b>type</b> Status report</p>

<p><b>message</b> <u></u></p>

<p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by the
    requested resource for the requested method.</u></p>
<HR size="1" noshade="noshade">
<h3>Apache Tomcat/7.0.42</h3></body>
</html>

elasticsearch – – Open Source, Distributed, RESTful, Search Engine

So, we build a web site or an application and want to add search to it, and then it hits us: getting search working is hard. We want our search solution to be fast, we want a painless setup and a completely free search schema, we want to be able to index data simply using JSON over HTTP, we want our search server to be always available, we want to be able to start with one machine and scale to hundreds, we want real-time search, we want simple multi-tenancy, and we want a solution that is built for the cloud.

elasticsearch – – Open Source, Distributed, RESTful, Search Engine

So, we build a web site or an application and want to add search to it, and then it hits us: getting search working is hard. We want our search solution to be fast, we want a painless setup and a completely free search schema, we want to be able to index data simply using JSON over HTTP, we want our search server to be always available, we want to be able to start with one machine and scale to hundreds, we want real-time search, we want simple multi-tenancy, and we want a solution that is built for the cloud.