How to avoid and optimize network "choking"?

I’m working on an app for a sports club that loads a lot of data from external sources but it feels a bit “chunky”. The app is pretty much all JSON driven with location services, Facebook, weather, etc and the content is requested during application start. The app itself is smooth as silk with everything pretty much localized to it’s storyboard scene.

Does anyone have any advice on how to avoid “network choking”? [import]uid: 13560 topic_id: 32837 reply_id: 332837[/import]

I had the same issue with the casino i just built so had to rethink the way I used the json requests/posts etc. and had to think of it more like sockets as I didn’t feel like building a socket server :slight_smile:

What I ended up doing is two things first breaking up t he requests, and while it does create a little more overhead (connections etc.) on the server it seems to be smoother as the packets coming and going are smaller. The other thing I did was create network class that allows me to fire and forget most of the outgoing requests/posts.

I also ended up adding totalrecords and recordcount to “all” of my json requests so when they come back i can call them with timers to download etc. which allows me to continue to process other UI and logic without being bottlenecked then when the recordcount >= totalrecords i just leave that function or call a callback function.

Little long winded but basicly since you cannot do threads in lua what you can do is create “poor man” threads using timers and call back functions so your communications can run in the background without effecting the main interface.

Not sure if that helps as I am not sure what specific “network choking” you are talking about but above was my problem and solution. [import]uid: 174725 topic_id: 32837 reply_id: 130543[/import]

I had the same issue with the casino i just built so had to rethink the way I used the json requests/posts etc. and had to think of it more like sockets as I didn’t feel like building a socket server :slight_smile:

What I ended up doing is two things first breaking up t he requests, and while it does create a little more overhead (connections etc.) on the server it seems to be smoother as the packets coming and going are smaller. The other thing I did was create network class that allows me to fire and forget most of the outgoing requests/posts.

I also ended up adding totalrecords and recordcount to “all” of my json requests so when they come back i can call them with timers to download etc. which allows me to continue to process other UI and logic without being bottlenecked then when the recordcount >= totalrecords i just leave that function or call a callback function.

Little long winded but basicly since you cannot do threads in lua what you can do is create “poor man” threads using timers and call back functions so your communications can run in the background without effecting the main interface.

Not sure if that helps as I am not sure what specific “network choking” you are talking about but above was my problem and solution. [import]uid: 174725 topic_id: 32837 reply_id: 130543[/import]

You pretty much nailed it there. I did a temporary solution by just adding a splash screen for 2 sec while the app downloaded the content. Not the best but the user wont notice it anyway.

Right now I request my content in the “applicationStart” and “applicationResume” listener but I’m going to limit my content to let’s say latest 10 posts, 3 days weather, 10 latest photos etc… I think I’ll study how Instagram, Facebook, twitter how they handle data, what are their starting times, reloading etc…

But like I said, best is to limit the requests and instead have the user to press “reload” button.

Thanks for the input, open for more suggestions.

[import]uid: 13560 topic_id: 32837 reply_id: 130555[/import]

You pretty much nailed it there. I did a temporary solution by just adding a splash screen for 2 sec while the app downloaded the content. Not the best but the user wont notice it anyway.

Right now I request my content in the “applicationStart” and “applicationResume” listener but I’m going to limit my content to let’s say latest 10 posts, 3 days weather, 10 latest photos etc… I think I’ll study how Instagram, Facebook, twitter how they handle data, what are their starting times, reloading etc…

But like I said, best is to limit the requests and instead have the user to press “reload” button.

Thanks for the input, open for more suggestions.

[import]uid: 13560 topic_id: 32837 reply_id: 130555[/import]

You might also want to look at making a Node.js server that serves JSON data. I’d recommend this as Node.js is amazing :slight_smile: [import]uid: 144908 topic_id: 32837 reply_id: 130588[/import]

You might also want to look at making a Node.js server that serves JSON data. I’d recommend this as Node.js is amazing :slight_smile: [import]uid: 144908 topic_id: 32837 reply_id: 130588[/import]