English 中文(简体)
Creating a constantly updating feed like Twitter
原标题:

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?

最佳回答

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.

问题回答

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.

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.

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.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签