iOS Question Long Polling: bad performance in release mode

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,
currently I am working on an App which uses Long Polling to update text in real time. I know, in many cases it's better to use WebSockets, however this discussion shouldn't be the topic of this thread.

Here is my problem: In release mode the performance of the web requests is significant lower than in debug mode.
I have created a small demo project which interacts with a WebApp and demonstrates the issue (I feel uncomfortable to publish it for everybody as it contains some backend information, so please write here or send me a PM). I have tested it on a real device (iPhone 5s) and made the following obversations: If I write text slowly at the WebApp, the text is exchanged nearly in real time. But at some point in release mode, the requests seem to "get stuck" and no data is received anymore.
In which way code is executed differently in debug mode? I already have tried to run the requests in a background thread, but no success ...

Any help?

Jan
 

Sandman

Expert
Licensed User
Longtime User
It seems to be a two dimensional matrix:
- Compilation mode (debug/release)
- Typing speed (slow/fast)

For clarification, can you explain which combinations that work as expected and which ones that don't?
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,
can you explain which combinations that work as expected and which ones that don't?
Typing slow & fast in debug mode works fine.
Typing slow in release mode is ok but still not as good as fast typing in debug mode. Typing fast in release mode is a catastrophe, it seems that the code is somehow blocked in this case.

Thank you.

Jan
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
Are you sending a new request with every keystroke?
On the server side, yes.
The App sends a long polling request to the webapp with the hash of the last received text. The server compares the hash from the app with the latest hash of the text in the webapp and sends an update to the app if needed. Everytime the app gets an update or a timeout, it will reconnect to the server. Therefore one can indirect say, that also the App sends a new request with every keystroke.

Jan
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I think the problem is similar to when doing an ajax based autocomplete in javascript/jquery.

There I solve it with a key press timer that gets reset each time a key is pressed.

If there's a 500+ms delay then only the call to the backend is done.

If not things freeze due to the ajax/http calls and typing slows down.

sockets are indeed kept open so the overhead is way less.
 
Upvote 0
Top