Tue, 07/15/2014 - 21:06

I'm about to start my personal startup. What really worries me about this project is will I ever be able to finish it on time? It's a web + mobile app both connected to eachother. It's way too much for just one man and project has a complex structure.

Since I've been having fun with AngularJS and Laravel it seems just fine for me to go through the same road again. But this time, a big portion of project is about writing single-page real-time apps. I've been thinking about how this is going to work and how I'm supposed to write the REST backend in PHP to communicate with client side. The more I think about it, the more Meteor seems a more solid option for me.

It's a startup

How time consuming and complicated this one's going to be? Meteor biggest feature that hits the market is data synchronization. Writing my client side and server side both in pure JavaScript and being able to have direct access to database, meaning no more data loading from REST endpoints.

Usually when a better solution or a new technology like Meteor comes into the market, people get scared. It's like one of those WTF moments that shocks everyone.

I asked myself:

"I was doing it wrong all this time?"

Actually not wrong. But I'm going to be wrong and stupid if I never learn it. This actually reminds me of MongoDB and RoR. How mongo tried to solve cluster database problems and how Rails introduced a whole new level of MVC best practices. People try to ignore it first, but no matter how you're going to feel about it, it's gonna find its way in to the market.

So why should you spend your time learning Meteor rather than another web framework? Leaving aside all the various features of Meteor, we believe it boils down to one thing: Meteor is easy to learn.

It's a true statement, live page updates and data synchronization made me write 100 lines of code in different languages in only 10 lines of pure JavaScript. When a user makes a change, their screen updates immediately — no waiting for the server. If the server rejects their request or executes it differently, the client is patched up with what actually happened. That's it, real-time app with zero lines of code.

After all it's called a startup and I'm scared of not being able to finish it. I'm good with JavaScript, so there's not a long learning curve for me. It's all JavaScript from client-side to server and templating. Even MongoDb console.

Scaling

Actullay the biggest challenge in any real-time web app. Real-time updates for a thousand of users shed servers to pieces. I'm not going to details about what DDP protocol is and how meteor using it, differs from other frameworks but Meteor poll-and-diff technic mixed with Mongo oplog tailing is the key difference.

Image and graphs from MeteorHacks.com

Meteor is built on top of node.js and it's amazingly fast. Like every other application, scaling and performance depends on how you write the code and design the schema. Keeping a copy of each connected user state, takes a certain amount of server's memory. It's up to you what information you want to be accessible in client side.

MongoDB integration with Meteor framework calms you down. Since Meteor 0.7.0 they've implemented oplog tailing. It's a total game changer on how Meteor used to alert clients about changes in database and how it's doing it now. Cluster and multi-core hanlding is one of the important aspects of this project. I can use MongoDB replica sets integration with Meteor now.

Diagram of default routing of reads and writes to the primary.

A replica set is a group of mongod instances hosting the same data, let's divide them to multiple cores then.

One command to compile your entire application into a tarball. Unpack it anywhere there's node.js, run one command, and you're on the air. You're never locked into a particular hosting provider; you have all the code for the platform.

You'll have nodejs + MongoDB + Meteor all in one folder, bundled together. Scaling, is the reason.

Conclusion

Eventhough I'm developing the mobile app in ionicframework using AngularJS, I prefer to use a full stack JS on website too. Meteor is still on early development and hasn't reached stable version 1.0.0 yet and It's got around 18K stars on Github already. Try Meteor once and see how it goes, you'll regret not learning upcoming technologies.