DDP vs REST Backend


#1

Hi everyone,

We are developing a social based application for android and ios clients, and the backend of app is to develop in meteor.
We are little bit confuse which to be use DDP or REST for the mobile client. Application has twitter like functionality and also user can chat.

Everything is freezed. Please help us to find out the best out of DDP or REST and In which way any suggestion.

Thanks.


DDP and RESTful APIs
#2

hey,

you can use both.
DDP is used by meteor and you cant change that that easy
but if you want a public rest api yo can use this: https://atmospherejs.com/nimble/restivus

i dont understand what you mean with: “for the mobile client” ? how are you developing your mobile app ?


#3

Hey,

from my point of view using DDP on a mobile client only makes sense if you need live data.
Like explained in the description of DDP it is something like “REST for WebSockets”.
You can either use DDP on the mobile client using one of the different libs available or use restivus like lampe said and build your API.
The advantage of using DDP is of course that you have access to most features you already have implemented on the server side whereas using REST you will need to call these methods again when using the API.

If you want to use DDP which I would recommend for you app since it is something like “twitter with chat” you should have a look at these libs: http://meteorpedia.com/read/DDP_Clients
I personally think using DDP is a lot less work if already have got your website up. If you use an REST API you will need to define the routes and all that stuff but that is just my opinion.

DDP makes extremely sense for the chat since that data is fetched live :wink:


#4

We are developing native app for android and ios . But we are not sure which should be best out DDP and REST.


#5

Yes, you are right we have done all R&D how to implement DDP and REST. I was thinking for chat we’ll use DDP and the other things should be done via REST. Because in the native ios/android there is no Blaze like templating engine and also DDP will consume more battery, internet and bandwidth .

what should you say ?


#6

Using DDP for chat makes more than sense.
Since I am not involved in what functionality your app provides I cannot tell how much sense it makes to for example to get all “tweets” as live data.
I am also not sure how much more DDP will consume since if no data is send there are only heartbeats right? But of course you are right it will save battery and bandwidth.
So your idea makes sense.


#7

In DDP there is also problem of file uploading. :disappointed:
Do you know any best way to upload images and videos via mobile ?
and About sending push notifications via meteor server ??


#8

Could you be more specific? What is the exact problem?
I actually dont know how to use DDP to send PushNotifications and if that is possible but you can of course use GCM to send Push Notifications from your server to the device.
If you use Cordova there are some packages which make it simple but since you write native apps you will need to have a look and maybe test it with the libs already given.
I never tried to send push notifications and do file uploads from mobile clients via DDP.


#9

I am working on push notification. i also don’t know how to send push notification. there is a package to send push notification https://atmospherejs.com/raix/push. i am working on this, soon i will find solution.

Now problem is how to upload files from from mobile client. if you find anything please share.

Thank u …


#10

Ok the package looks good. I would give it a try.
I still do not see a problem with that. What is the problem with uploading files from the mobile client?


#11

Problem is in which format we can upload file, the file size, file compression, uploading time etc. we should use amazon s3 service to upload files. this full module is under R&D. i am wondering if anyone can guide me on this.
Actually i am also not sure about all problems. we are working on this so, we can replicate .


#12

For mobile I don’t recommend using DDP. My biggest concern is DDP getting blocked by a firewall. You’re using Meteor as a backend and, as far as I know, there’s no sockJs port to iOS and/or Android. If you use Meteor to develop the mobile app, sockjs will save the day.

I think REST is best option for your scenario.


#13

Could you explain it a bit more why you wouldn’t use DDP on mobile I dont get it completely what you are saying?
I understand that you have the concern of getting blocked by an firewall (whyever).
What is the problem of not having a sockjs port to Android or IOS?


#14

You wrote that you want to use Meteor as a backend, in my head it’s translate into: We’re using another framework at the front end. If you’re not using javascript at the front-end, you won’t use sockJs unless you write your own version. It means that you can try to use DDP in your mobile app but if the web socket connection gets blocked, you need to write fallback code and also a REST API.

You end up writing a REST API at the end. Keep in mind that I don’t know if this potential issue is relevant. In a Meteor hangout a startup ( Classcraft ) had this problem but got lucky because the sys admin allowed web sockets. ( I was the guy who asked it in the hangout video )


#15

I don’t get an issue related to firewall blocking, we have done experiment on this through native ios framework using DDP client. we did not replicate this issue.

But i’ll also prefer REST API, because there is no proper support for this and lots of issue for mobile client like bandwidth, battery, file uploading etc.

For now we’ll go with REST API bit in the future i’ll surely use DDP for the live data of feeds and messages.


#16

I’m actually working on a similar project and I’ve learned some things along the way. Hopefully this can help you. Here are some things to consider:

  1. DDP will give you reactive data. Certainly use this for chat, but no reason not to use this elsewhere.
  2. DDP (using merge-box) will make sure you don’t send repetitive data over the network, reducing your network load.
  3. I don’t think DDP will have any effect on the battery life of your device. Its using less bandwidth and marginally more computation (devices are so powerful now).
  4. For any native client, you’ll have to build or use someone’s DDP client. The guys at Workpop are using meteor-ios so I think its safe to say that will be a stable solution for a while.
  5. social apps tend to be very relational. Mongodb isn’t just terrible at relational queries – its not meant for relational queries. So think hard about the most challenging queries you’ll have to do and if you end up with a giant $in: [id1, id2, id3, ....], then you shouldn’t be using Mongo.

One solution I’ve been working on is the ccorcos:any-db package so I can use a relational database (I’m using Neo4j) as opposed Mongo. You can define dependencies manually and get reactivity. Or you can just send data to the client as if its a REST API, but using this package and DDP will make sure duplicate data isn’t sent over the network.

Another thing to consider is Native vs Cordova. There are LOTS of trade-offs here.


#17

Thanks ccorcos, for your precious time. for the now i have started with the REST time. but after the completing the base of the app we’ll focus on the DDP.

And i don’t think there is any problem using Mongodb. We can handle this very well to make database relational easily. i had created the database architecture in mongo and its working perfect. i didn’t find any problem in mongo as doing the third project in meteor.

My main problem is now File Uploading https://forums.meteor.com/t/file-uploading-using-rest-apis/7602 .
please help me over here .


#18

how to sett up server for this library, I made an android native app with https://github.com/delight-im/Android-DDP
library and I use meteor for my web service. I dont remove insecure
package and autopublish package. so I can Insert, delete and update
without subscribe or call the method in client.
but my problem is I can not connect to my localhost. I use genymotion for the android emulator.
Any one can Help me, please, Thank you
It’s my first time to work with Web Socket,
here is my code
https://ideone.com/pXzJW8