I have been working in the CakePHP framework for some years. It's good for enterprise web application but somehow its performance is very much low on doing some database and email related task.
Now I'm looking to learn new framework either based on Node.js or PHP, but it should produce an ultimate performance when doing large database operation and sending bulk emails.
So please let me know your valuable suggestions on this.
@nitinbhojwani, I wouldn't really agree with point 1 and 2. You talk about threading concurrency, and data abstraction models. Now, let me explain what I am trying to say by continuing with your email example. Your method of implementing the email is not necessarily wrong, but it can do with much improvement. Imagine that the function you are trying to write sends an email everytime someone posts an ad on your website. Now, with a couple of users it's fine, however, if the user-base is huge, with every post the number of emails sent will grow as well, thereby slowing the request-response loop. (Further down, I have talked about how to fix this)
About databases. PHP and Node, are both homeomorphic when it comes to data accession. Now, I do agree with the ease and simplicity in PHP, but it's more or less the same. Have a look at bookshelf.js for an ORM. Really easy to use! :)
Moving onto the meat of the answer.
I know how painful migrating from one language to another is, and therefore, I would give you some advice about how you can make this faster. It would require you to refractor the infrastructure, but not the base-language.
Let me introduce to you the concept of Microservices. I wouldn't really go into the depth of it as I have covered it here.
But, it its essence it decouples your architecture. So a task like sending emails, you know it takes time, so you create a small program which sends the email. To feed what to send, you start a queue (Redis, RabbitMQ) and whenever you want to send an email, you just push the data to the queue. Now, this operation is super-fast, so it doesn't lag your API (backend). The program is watching the queue for changes, and as soon as it gets a new job, it pulls it, sends the email, and deletes it. You just solved the first problem
Again, microservices. Now, depending on what sort of operation it is, you can either decouple it into a microservice, and let the workers process the data, or you can have independant services fetching data, and another service collating it. Super quick. Also, try modifying the data schema you have; personally, I would go with this first. I have seen what sort of boost this gives. And as an added bonus, it will save you from the later headache of migrating, backing up, and whatnot.
Also try using some different database engine. I prever MariaDB as it provides SQL + NoSQL, all in one engine with Galera clustering. Really useful!
With that, you solved the second problem.
Alright, alright! I will destructure this based on my personal experience. :)
Now, @nitinbhojwani suggests Express. Perfect! Really simple; quick to get started with; powers huge applications, but I don't really like it.
In my opinion, Hapi.js is the framework of choice. Just have a look at the list of "getting started" tutorials to see what I am trying to "say."
However, the problem you might face with Node is the intricacy. We had a production API server running on node, and we saw some really huge performance lags; the cause? We were using Undersore. A function in Underscore was a little inefficient. Now, after switching to Lodash, all of it was gone. To understand what really went wrong, we had to analyse the entire infrastructure on which Node runs; from the VM to the accession libraries.
That's not the problem with PHP. I mean, you can write some really inefficient code in both the language, but according to me, in Node, it's super-simple if you have a working knowledge! :)
If you have any other questions, feel free to ask me! I'd love to answer them! I hope this helps! :)
If you still want to play with PHP, you should use PhalconPHP. The frameworks of old generation like Cake, Yii, Zend... are not good for performance. I like the creative concepts in Laravel but this framework is based on Symphony. If you have much experiences and time, take a look at HHVM, PHP7 and something awesome last year.
I've switched from PHP world to Node.js several years ago and no plan to comeback. In Node.js, the most popular framework is Express. Otherwise, you may like its next generation, Koa. For building Restful API, just take a look at Restify, Hapi and LoopBack. If you need a blog, use Ghost.
Node.js and PHP are both good. And you can achieve what you want by going on with anyone. But, it's about ease too.
So, Let's discuss them on few points:
Synchronous or Asynchronous - This must be the most dominating factor for deciding. If you want to be blocked until previous operation is over, that means you are looking out for synchronous else vice-versa. Email-sending, in most of cases is kept asynchronous. So, Node.js will be the better if you want to send bulk-mails asynchronously.
Database - PHP will be better with SQL database and Node.js will be better with NoSQL or storing JSON object. Of course, it's not like hard coded, You can use otherwise too.
Performace - I think for your use case Node.js will be better, as it is very well in non-blocking type of applications. You can go through below link as well. hostingadvice.com/blog/comparing-node-js-vs-php-p…
Ease of writing - PHP has easier syntax. Node.js, being JavaScript, as we know, is all about curly-braces and parentheses and then keep counting them. But, if there's front-end also involved in your application then Node.js might help you, by preventing the syntax/context switches between front-end and back-end code
Now, in terms of framework,
Symfony2 is the one I'll go with if I choose PHP - LAMP or LNMP stack
ExpressJs, if I choose Node.js, which is the most commonly used framework for Node.js - MEAN stack
Your problem is not the PHP framework. It is the pattern you probably use. You try to send the emails and do jobs that are slow in their nature inline, and it takes too long until the server gives back a response. For that, you should use Queues. As for database, if it is slow now, it would still be slow in the next framework, since is another kind of optimization you must look for. Furthermore, one of the reasons your database access is slow, is because you do things in your database you should probably not do. Stuff like logging. Those things eat a lot of time and slow down everything. For that, look into something like Redis. You can use any framework with those concepts and have decent results. Have a look at this: https://www.youtube.com/watch?v=bTcyuzJkxIg
@champ You stick at PHP. #laravel is the best framework. It is powerful, easy and lots of support.
Samuel Oloruntoba
Java is to JavaScript what Car is to Carpet.
Looking for raw performance. PHP can compete with node anytime. It just has to be PHP 7 on a LEMP or LEPP or whatever architecture you use, just make sure it has Nginx. PHP is better at handling large stuff like this.
Also, Laravel is pretty good at handling email and database related problems, and it does it pretty fast. But if you still need more speed, try Phalcon.
For node, use sails.