Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any benefit of using Node.js for APIs over normal apis created in PHP etc for mobile applications?

Tags:

php

node.js

ios

I am an iOS and PHP developer and learning Node.js now a days. Node.js says that it is event driven and server can also push data to client.

I am wondering if it would be helpful for mobile apps in any way. Following are the queries arises in my mind :

  • Can server push data to mobile apps also while using APIs? Currently only mobile request data from server by passing parameters to APIs and server respond to it accordingly (Typical request response handling). By using node at server end does it mean that server can reply something to device also(Something like Push Notifications )?
  • Is there any performance benefit at mobile end while using APIs? I mean if we have to display collective user count etc on mobile device, in real time (For example something like Facebook like count).

Any help would be appreciated.

like image 501
stackNeverFlow Avatar asked Nov 23 '25 18:11

stackNeverFlow


1 Answers

As per my experience using Node.js for some apis is very much useful when you are using chat applications, or applications that needs real time information about data changes over other devices or web site admin panel(like file storage application dropbox). For example you are uploading one file through browser in your admin panel. So after upload if you need information about the new file on the device you can do two thing 1. Checking the file system api continuously which is data and cpu consuming. 2. Use node js to send a command to the device so that user will know that file has been uploaded and you download it.

For normal api like login register i don't think it is that much useful. But if you want to log out one user when he/she logged in from another device, you should use node js so that you don't have to check the user login validation every 30sec or 40 sec.

But there are few problem with node js, with very large number of users accessing the node js server, it might go down. So in that case you can use load balancing in the server so that every user doesn't use the same port for accessing the node js server.

And personally i prefer node js over normal api.

like image 84
souvickcse Avatar answered Nov 26 '25 11:11

souvickcse