Google Web Engine Api Channel vs Node.js+Socket.io - html

Please, help me to choose which one to use for my university project (I want to develop a shared multiuser whiteboard).
In particular, I am interested in the performance of message exchange between users and server using Channel API and Socket.io: which one is quicker and why?
I have implemented an initial version of the whiteboard http://jvyrushelloworld.appspot.com/ by following this tutorial: http://blog.greweb.fr/2012/03/30-minutes-to-make-a-multi-user-real-time-paint-with-play-2-framework-canvas-and-websocket/ The code I used is pretty much the same, except for the side and message exchange method: I used python, Google Channel API for message exchange; the guy who wrote the tutorial used Play 2 framework and Web sockets.
As you see, the web socket tutorial version works much faster (don't know if it is my mistake or google api channel performance issue). Of course, a lot of optimization can be done to improve the performance, but I wonder if it is worth to go on using Channel API for that project or is it better to switch to socket.io?

Related

Connect Sproutcore App to MySQL Database

I'm trying to build my first Sproutcore App and I struggle to connect it to a MySQL-Database or any datasource other than fixture. I can't seem to find ANY tutorial except this one from 2009 which is marked as deprecated: http://wiki.sproutcore.com/w/page/12413058/Todos%2007-Hooking%20Up%20to%20the%20Backend .
Do people usually not connect SC-Apps to a Database? If they do so, how do they find out how to? Or does the above mentioned tutorial still work? A lot of gem-commands in the introduction seems to already differ from the official Sproutcore getting-started-guide.
SproutCore apps, as client-side "in-browser" apps, cannot connect directly to a MySQL or any other non-browser database. The application itself runs only within the user's browser (it's just HTML, CSS & JavaScript once built and deployed) and typically accesses any external data via XHR requests to an API or APIs. Therefore, you will need to create a service wrapper around your MySQL database in order for your client-side app to be able to load and update data.
There are two things worth mentioning. The first is that since the SproutCore app contains all of your user interface and a great deal of business logic, your API can be quite simple and should only return raw data (such as JSON). The second is that, I should mention that the client-server design, while more tedious to implement, is absolutely necessary in practice, because you can never trust the client side code, which is in the hands of a possibly nefarious user. Therefore, your API should also act as the final gatekeeper to validate all requests from the client.
This tutorial I found helped me a lot. Its very brief and demonstrates how to implement a very simple login-app, how to send post-requests (triggered by the login-button-action) to the backend-server and how to asynchronously process the response inside the Sproutcore-App:
http://hawkins.io/2011/04/sproutcore_login_tutorial/

CouchBase WEB(AngularJS), Android(Native), IOS(Native)

I'm planning to build an application that runs on WEB(AngularJS), Android(Native), IOS(Native).
I have experience with MongoDB, but I found CouchBase which sounds really good for me.
I read documentation and I found out I need to use sync_gatway to sync my mobile databases with main database server and reverse, until now everything is fine.
I also need to use "channels" to share records with multiple users.
The problem comes when I need to implement this for web application.
In their documentation on "Working with web applications" they explain how "bucket shadowing" is working, but they also say:
Bucket shadowing is meant to enable sync for existing Couchbase Server
apps. If you are creating a new app with both mobile and web clients,
we recommend starting with the Sync Gateway REST APIs, and connecting
backend services using the Changes Worker Pattern.
After reading Sync Gateway REST API I found out I'm limited to facebook and persona authentication. So I can't use my own authentication mechanism?
Also, there is nothing specified in REST API about channels?
Is there any example project or more documentation about this? I couldn't find anything :(
If someone has experience with this, please explain how this works.
Thanks
There is also Custom (Indirect) Authentication available on Sync Gateway, which you can use for any type of auth you need.
But you have to hide Sync Gateway's Admin API under your backend layer.
As for the channels: it is responsibility of Sync Function to route different documents to necessary channels based on Document data.
Here is a good video that describes how to build production architecture around Couchbase Lite.
I'm probably late for the party - but as of today I'd recommend taking a look in the PouchDB project for the WEB AngularJS side - they match pretty well and will sync with Couchbase.
Regarding authentication, I just released an article on that topic, find it here. Hope this helps somebody

An alternative to app engine to use drive api?

I basically want to write an app that uses the Drive API. developers.google.com has tutorials on how to do that. But problem is that their example asks me to first create an app engine instance, which I don't want to, as I've heard pretty bad reviews about it. So, I just wanted to know whether there is/are any alternative/s available, and what challenges I would possibly have to face when using the service/s.
You can write a Drive app on any platform that can make an HTTPS request, so pretty much, any platform. When you choose one, if you have any problems, get back to us.
Also, you should probably try out App Engine before making a decision based on "reviews you read".
AppEngine has a few convenience classes around Credential storage and User Id. Aside from that a standard servlet app and a GAE app are pretty much the same.

Database Driven iOS Apps

So this is more of a general question about apps and techniques rather than a specific code question...
When developing an larger app, how would a developer access lots of data from a website. The example I'll use is an app like Yelp. They have both a web-access site and an app, both share the same information. I would imagine that information like that is stored on the website via some sort of MySQL database and the iOS device access's it as needed based on the user's requests.
How might a developer writing an app start something like this? I assume you need to somehow securely tie the MySQL database to iOS and so on. I've seen a lot of techniques on the web, but they all seem very simple and not safe for a large scale app.
Any ideas would be awesome!
The key term you're looking for is "API" (Application Programming Interface).
A Yelp iOS app won't access Yelp's databases directly. There will be a layer (I simplify here somewhat) between that and the iOS app; this layer will provide a series of methods (the API) by which clients can make queries and potentially manipulate remote state.
A common API format is JSON over HTTP, and indeed, this is what the official Yelp API seems to be.
Good starting points would be the documentation for NSURLConnection and NSJSONSerialization, and the Yelp API documentation I link above.

Feedback on this back-end stack

I'm planning to setup an scalable architecture capable of providing web services on a REST interface where JSON will be sent as a result.
The web services will be quite simple for a CRUD web 2.0 app.
I think javascript (nodejs + mongodb) is a good choice for the following reasons:
Easy to find javascript developers
Good performance
Easy to scale
Shared logic/language or possible reuse of code between database query language, back-end and web-client.
There are testing and logging frameworks for node
By the examples I've seen node seems light in terms of the lines of code needed to implement web services.
Questions:
I think of scaling a node app which supplies a web service as having
a central node which will be routing/balancing charge to each of the
node instances. Which will also help doing seamless updates, is
there any piece of software already implemented which can fit that
task?
Please point all the disadavantages or other advantages you find in this back-end stack
If you feel this question opens too much of a debate and doesn't fit the stackoverflow policy please indicate a forum where I could get feedback.
Any other good persistence choices other than MongoDB? Mainly this choice comes from the javascript query language and JSON schemas.
Regarding your "router" piece:
Since your REST api will be composed of HTTP requests, it's common practice to use a high-speed proxy such as NGINX or HAProxy to distribute requests among the many servers who actually perform the work (in your case, NodeJS servers). This generally works well and allows easy scaling and failover.