Pregunta

I have android inventory app. At this moment app is communicating with server via https. I have already gzip enabled and it is working. When users scan barcode, app is sending that code and also phone ID to server. I do it via XML. Then servers responds with xml witch contains some data. Like amount in each warehouse is, price, product name. Then user confirms amount and app is sending again to servers and responds with message (ok, or not ok).

When inventory is via WiFi, that's not a problem speed is good, latency low. But when inventory is via mobile network, then communication is with latency. Do i need to create binary format for communication? And XML data has large overhead (unneeded data like tags, etc). Or there is some standards or best practices with data amount minimization in communications ?

¿Fue útil?

Solución

If you are primarily concerned about reducing the size of your payload, you definitely want to look at a different format from XML. One popular option is protobuf from Google.

Otros consejos

You can't adjust latency from the app. You can make your payload smaller to speed up transmission but that's about it. Look into JSON. It's significantly more lightweight than XML and it's natively by almost every language.

If there are too many requests happening from the client to your server, you might consider changing your server APIs. For example, in getting the inventory you could have separate API for getting the categories of products, then after getting the categories, you issue separate calls to get the products for each category, the for each product there is an API to get the details. To minimize the number of requests you can create a single API that gives you all the categories, all products under each category and the details of these products. This approach will lessen the number of requests between your client and server.

If the size of the payload is really big, you can try JSON which is more lightweight.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top