A
A
Alex Kheben2014-07-30 15:51:55
PHP
Alex Kheben, 2014-07-30 15:51:55

What is the best way to organize a REST API (with MongoDB storage)? Nodejs or PHP?

I have been writing in PHP for a long time, everything is clear with it, but I recently met Nodejs and I liked it.
I am interested in reasoned facts, pitfalls, features, etc. when working with Nodejs versus PHP. Also interested in the issue of Nodejs performance and tools for more convenient development (extensions for SublimeText and other utilities).
PS: Nodejs enjoyed working with MongoDB through mongoose. There is less code (on Restify + Mongoose) than with any PHP framework I have worked with (Yii2, Phalcon and a few more).

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey, 2014-07-30
Protko @Fesor

for RestAPI unpretentious norms. In terms of performance, it consumes more memory than PHP, but it works faster and allows you to raise RPS. It would also be a good practice to raise several application intans (one per core and leave one core in reserve) and proxy requests through nginx to these instances.
For mongi + RestAPI it is quite justified. If you take another framework like express or something more specific, then there should not be any particular problems. Unfortunately (or fortunately) I tried mongu n production only once, got upset and scored. On node.js I usually keep daemons for sending notifications (APNS/GCM/WebSockets).

A
Alexander Kubintsev, 2014-07-30
@akubintsev

I think that raising several instances is a fundamental moment to compete with php, since php-fpm workers utilize all server cores.
One more thing: if there is a lot of business logic or intensive calculations inside request processing, then php workers will also be preferable, because in the case of node.js, the entire instance will slow down.

A
Artur Smirnov, 2014-07-30
@artursmirnov

I think NodeJS is better for working with Mongo. RESTful APIs are easy to pull up with Sails.js . There will be even less code with it;) As for performance, there have never been problems with Node.js, but I ate on PHP in due time. Right now I would choose Node.

C
cybervito21, 2014-10-22
@cybervito21

NodeJS + Mongo + Mongoose, at least writing is fun!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question