Phalcon php vs node.js

11,544

Solution 1

You are trying to compare two different things IMO.

node.js has a lot of power and flexibility but so does Phalcon. If you want to create a chat application with Phalcon, then you will need to implement some sort of polling mechanism in your browser that would refresh the chat window every X seconds. Getting/Inserting the data from the database will be Phalcon's job. Javascript will be used to do the polling i.e. refresh the chat page every X seconds.

The problem with this approach is that you might be hitting your web server every X seconds from every client that has the chat application open - and thus refreshing the chat contents, even when there are no messages. This can become very intensive very quickly.

node.js has the ability to send messages to the subscribed clients instantly. Web sockets can do the same thing I believe.

Check this video out, which will give you an idea of how this can be achieved easily:

https://www.youtube.com/watch?v=lW1vsKMUaKg

The idea is to use technologies that will not burden your hardware, rather collaborate with it. Having a "subscription" notification system (such as sockets or node.js) reduces the load on your application since only the subscribed clients receive the new messages and no full refresh is needed from the chat clients.

Phalcon is great for the back end with its speed and it can be used to construct the message which in turn will be passed to the transport layer and sent to the client. Depending on how you want to implement this, there are plenty of options around and you can easily mix and match technologies :)

Solution 2

as @Nikolaos Dimopoulos said, you're trying to compare two different things.

But here is my advice, while you're experienced with PhalconPHP framework, and you want to benefit from Phalcon speed and performance, you can implement the web app in Phalcon FW, and the chatting system in Node.JS as a service.

If your web application "The Phalcon app" needs to push messages from the backend, you can use http://elephant.io/ library for that, I have done this before with Yii framework and Node, and it's working perfectly.

Solution 3

My advice is to use what you already know, experimenting with nodejs just for the chat application.
Mainly because you said you do not have experience with it, so, because the chat app is something a lot of people made you'll find plenty of examples.

By doing so you will learn a lot from node and might even think about migrating from Phalcon if it suits your needs, using the features offered by expressjs for example.

I would not choose one over the other based on performance.

Share:
11,544
Iliya Garakh
Author by

Iliya Garakh

Founder, growth hacker at passwork.me Founder, CTO at primepix.ru Part time technical consultant

Updated on June 12, 2022

Comments

  • Iliya Garakh
    Iliya Garakh almost 2 years

    We are going to develop rest server for our application (and all logic is on client javascript). So we thought to use Phalcon php, but we also need to create realtime chat system, which is much more easy to do using node.js. This made us think about using node.js instead of phalcon

    Unfortunatly, we are not good expirienced in node.js, we love phalcon for its performance and internal beauty.

    The quiestion is, did anybody compare phalcon and node.js performance? May be it's better to use node.js only for long polling chat requests, but i dont like when project is connected with so different tools.