Skip to content Skip to sidebar Skip to footer

How To Improve Performance For Android/ios/etc To Consume Web Service?

We are planning a a project. Basically we have tons of restful services sitting on our server. These restful services will return XML as data type. We will build apps on various mo

Solution 1:

Use JSON data format.

It's faster to generate on your server, faster to transmit over network, and faster to parse and consume on the device.

Solution 2:

I wouldn't worry too much about this ahead of time. Just try to keep your data structure reasonably efficient, and if you run into measurable problems, then you can optimize at that time. The overall performance should be similar on the different platforms.

See this Android article on designing for performance. It provides a good overview.

Solution 3:

When creating a system like this, it's easy to get into the mindset of maximizing the work done on the server in order to minimize the amount of work that has to be done on each client device. This isn't necessarily the right way to go.

Generally speaking, smartphones are more powerful than programmers tend to give them credit for, and - like PCs that spend most of their time just sitting there - their processing power can be be underutilized. As long as you code in a basically sane manner, smartphones can parse large amounts of XML quickly (depending on your idea of "large", of course - for example, I know from personal experience that a crappy 3-year-old Blackberry can parse a 5 MB XML doc in just a few seconds, but you might think 5 MB is small).

If you go too far down the road of doing extra work on the server in order to lessen the workload on the device, you might well end up overloading your server while underutilizing the power of the devices. It does make sense to compress the data returned from your web services in order to reduce the overall size of what's being transmitted, but then that would suggest not using XML in the first place.

Solution 4:

The worst problem is the payload itself: XML is too bloated. Each non-empty tag needs 2*N+5 characters. This is a pain to both parse and transmit. Much better is a JSON payload. If you cannot change the producers, create a façade to make the conversion.

Post a Comment for "How To Improve Performance For Android/ios/etc To Consume Web Service?"