问题
Q: What kind of data-type would be the most efficient/fastest to use when transfering data between a webserver(/other?) and a mobile phone, ie ios/android/other?
- JSON ?
- XML ?
- HTML ?
Q: What kind of serverside technologies should be used?
- php + mysql ?
Q: What kind of API should be used?
- Restfull?
- RPC ?
Any thoughs ?
回答1:
A1. Binary.
Have you looked at Google Protobuffers? this is an efficient binary formatter with cross-platform capabilities (java, c#, python, objective c, PhP. There's even a JScript implementation knocking about but I wouldnt trust it!)
Have you looked at messaging frameworks such as AMQP? I have successfully implemented a cross-platform binary messaging system using AMQP as a message router, Protobuffers as binary serializer and Rabbit MQ as C# and Java client. It was extraordinarily fast and could perform a roundtrip request/response from client to server and back (including serialization/deserialization, excluding network times) in only 0.5ms.
The messaging stack becomes:
Mobile > RabbitMQ Client > Google Protobuffers > {the internet} > RabbitMQ Server > Google Protobuffers > Webserver
JSON is your next fastest serializer but nothing can compare to binary for speed and efficient use of bandwidth.
A2. For performance Oracle will handle the most data, SQL Server and MySql will give very good results though depending on what you intend to do.
It also depends on how your data is going to be stored. Are you storing relational data? Then use a relational database. Are you storing time series data? Then use a column-ordered database or even a flat file. PyTables is an excellent example of python-based file centric database which is highly suited to storing scientific datasets and timeseries.
The answer to this question really is "It depends" - on what you want to do. I would also consider developing in a serverside technology you know well rather than pick one based on numbers as they are all fairly similar.
A3. Unknown, not my area of expertise.
Best regards,
回答2:
First of all, what do you mean by efficient? In regards to mobile network performance, I would assume you are talking about what would be the lowest latency from sending the web-request to receiving the response.
If we are talking small amounts of data (<~100kByte) the format probably would not be that important, the RTT will be much more important than the throughput, thus you can choose freely between JSON, XML, etc.
For larger data amounts the verbosity of the textual formats you mention might become a significant factor, as the throughput will become the bottleneck, and you could consider just gzipping it, e.g. JSON+gzip. That will cause a processing penalty.
You could probably do some testing to see when the benefit of compressing the data outweighs the penalty of the processing required for compression.
回答3:
A1
It's not just about the transfer it's how it's going to be processed on the client side e.g. is it being retrieved using a HTML client?
Latency is a real killer on mobile, but memory is a also big issue - I'd choose the format that is easiest for the client to handle maybe JSON(P) but I'd want to look at the data/application in more detail to make a real recommendation.
If you're writing a native app it's certainly worth considering a binary protocol like ProtoBuffers or Thrift but I'd be tempted to knock up a prototype using JSON or one of the other text formats first.
A2
Probably what you know best (within reason)
A3
I'd go for REST on the basis that some requests will be GETs.
RPC suggests that the requests will be POSTs and some browsers split AJAX POSTs into two TCP packets, the second of which is only sent when the first is acknowledged (bad in high latency environments).
回答4:
Dr. Andrew said: "It depends". All depends what kind of application you are developing. Give us more explanation!
来源:https://stackoverflow.com/questions/8710654/mobile-network-perfomance-what-would-be-the-most-efficient-data-type-to-transfe