views:

150

answers:

4

I'd like to have something in my app that is just like Twitter but not Twitter. Basically it will be a place people can submit messages and do not need an account. They only way they can submit is through the app. I want other app users to see the submitted messages nearly immediate. I believe push notification can do that sort of work but do I need push notification for this? How does Twitter do it?

-- EDIT --

After reading some of the responses, push might be what I need. People will be submitting messages to my server often. If someone is watching the feed, they might see one new message per minute depending on the query they are using. I'm thinking to go with a MySQL database, (which allows switching to cheaper non Windows servers w/o much hassle) and push notification. Are there any reasons those won't work for my scenario?

+2  A: 

You only need push notification if you want the app to be able to receive new messages while closed.

Here's a rough description of one way to do this: Your app sends a message via HTTP Post to your server. Your server stores the message in a database, using the iPhones unique ID as an identifier. Your app connects to the server frequently, asking for new messages. If there are any new ones, the server hands the message to the app, which displays it.

This is approximately what twitter/iphone twitter apps do.

Kenny Winker
+1  A: 

Might want to take a look at XMPP.

Twitter doesn't really push events out to the iPhone in realtime. It's more like polling by the various clients.

If you really want instantaneous for the last mile you'll want to use push.

Ramin
A: 

Twitter uses lots of servers and raid arrays to handle the load of millions of people posting 140 character messages. Twitter clients log in and request a list of updates for all of the people the user is following within a certain time frame.

Push wouldn't be a good candidate for this because it does not persist the "tweets". It is simply a notification mechanism. There is a text messaging app on the App Store (called Ping!) that relies completely on push notification for sending text messages. This seems to work fine, but if the developers are keeping track of the messages, it is all done on their servers. In their case push makes sense as you want to alert the user of a new message. In the case of a twitter clone, however, it would probably just annoy users if they got a new notification every time someone tweeted.

In the end you're better off just implementing it server side and then developing an iPhone client that logs in and retrieves the latest tweets for the people the user is following.

Matt Long
+1  A: 

Your choices are fairly binary:

  1. Use push notification
  2. Use Polling

With Push Notification:

  • You control when you contact your users... Heavy Load means you can slow updates down to avoid taxing your infrastructure
  • Contrariwise, you have to push to clients that may not even be there anymore (And thus may need some sort of register model), high load may mean that clients don't get immediate update
  • You can leverage things like Amazon's EC2 to give you more processing power
  • Unless you're out of capacity, users are almost certain to be receiving updates as they happen
  • To pick up messages missed while offline, the SERVER needs to know what message was last successfully received, store older messages and forward many all at once

If you choose to use polling:

  • You must have a stable address to be polled
  • You need the ability to have lots of quick query connections checking for new data, then returning that data if required.
  • If your application becomes popular enough you may find you don't have enough resources
  • If your resources are taxed your application will go down, rather then just slow down
  • You don't need to register clients and keep track of their on/offline state
  • Parallelizing on the fly is a bit trickier
  • To pick up older messages, the CLIENT needs to know when they last received a message and then request the server send any message since that time

Both can be fast, but they come with different bandwidth and processing profiles. I prefer push for everything that's real-time.

Dylan Lacey
There's also the third possibility of keeping an open IP connection with the server.
jtbandes
Sounds like push may be for me. For now, I don't need to notify people when the app is closed. Updates to a feed might be about one very minute and could become more. Is push good for that? I've updated the question in regards to database.
4thSpace
@jtbandes good point. Since we're looking at that for work, you'd think I would've realized. Doh.@4thSpace - You're going to have NumberOfUsers worth of transactions a minute. Whether your servers can handle that depends on your server infrastructure, hosting, bandwidth et al. I don't foresee any issues with reasonable numbers of users. Allow open devices to register then just push to them until they stop responding to new pushes, at which point wait for them to re-register ('cause they're likely closed or incommunicado).
Dylan Lacey
@Dylan, thanks. Do you see any issues with using MySQL as a backend database? Or is there something else you think might be better?
4thSpace
@4thSpace: Not really. If you're not doing anything tricksy that relies on database specific features, you can use any database you like. MySQL has a lot of community support and a commercial development plan, and can run on Windows and Unix. So I say go for it.
Dylan Lacey