Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any success using Apache Thrift on iPhone?

Tags:

iphone

thrift

Has anybody done or seen a deployment of Apache Thrift in an iPhone app?

I am wondering if is a reasonable solution for a high-volume, low(er)-latency network service for iPhones compared to HTTP.

One noteworthy thing I found is a bug report about running Thrift on the iPhone, which seems to have been fixed. But that doesn't necessarily indicate that it's a done deal.

like image 215
JasonSmith Avatar asked Dec 11 '09 18:12

JasonSmith


2 Answers

Thrift and HTTP aren't mutually exclusive. In fact thrift now ships with an HTTP transport implementation to use. It's also a really nice way to auto-generate server/client code that avoids a lot of marshalling/unmarshalling boilerplate while still being really fast. Its internal representation is basically binary JSON, so it's very similar to a RESTful web service (except being easier to code and much, much faster).

So... anyone able to answer the original question? If not, I'll dive in myself with thrift's included Cocoa support and see how it works on the iphone.

like image 96
samkass Avatar answered Sep 23 '22 16:09

samkass


Just my two cents..

The accepted answer to this question, is an opinion to not use a technology, not an answer of whether it is possible.

Thrift, is an interface definition language, IDL, like Protobuf and Capt'n'Proto. They permit the definition of a client/server/server protocol which is platform agnostic. JSON and Plist don't provide the same level of type conformance.

Having previously lead an iOS team with 10Ms MAU using Google Protobuf v2.5 on iOS, Android, Windows, and server teams, I can attest that IDLs are great on mobile. Apple uses them for syncing iWork content.

My current team uses Thrift for iOS and Android clients, with a mostly Scala backend. I much prefer it to Protobuf.

We send Thrift payloads over HTTPS and WebSockets. Once you have defined (in Thrift) your our wire communication protocol (i.e. frame structure), it's very easy to evolve your APIs.

However, on iOS in particular there are some implementation issues. The current version of the library is quite poorly packaged, and if you hope to make an Objective-C framework (e.g. for iOS 8+), then you will not be able to out of the box with v0.9.2. This is because the library headers include local imports, (#import "TProtocol.h" instead of #import <Thrift/TProtocol.h>) with no umbrella headers. Worst of all, the Objective-C compiler generates very messy Objective-C classes, also including local imports from the Thrift library.

Some of these issues are pretty damning. It indicates to me that while use of an IDL is very much a good engineering decision, not many iOS teams are using Thrift, unless they're huge with the resources to write their own library.

like image 22
Daniel Thorpe Avatar answered Sep 20 '22 16:09

Daniel Thorpe