OPTIMIZING NETWORK IN MOBILE APP DEVELOPMENT Duc B.1, Thao L.2, Hieu L.3, Khoe N.4, Lam N.5, Huong L.6 (Russian Federation)
1Duc Bui - Master's Degree student, SOFTWARE DEVELOPMENT DEPARTMENT, FACULTY OF INFOCOMMUNICATION TECHNOLOGIES; 2Thao Le - Student, DEPARTMENT OF GEOINFORMATION SYSTEMS, FACULTY OF INFOCOMMUNICATION TECHNOLOGIES; 3Hieu Le - Student; 4Khoe Nguyen - Student, DEPARTMENT OF SECURE INFORMATION TECHNOLOGIES, FACULTY OF INFORMATION SECURITY AND COMPUTER TECHNOLOGIES;
5Lam Nguyen- Student; 6Huong Luu- Student, DEPARTMENT OF COMPUTER SYSTEM DESIGN AND SECURITY, FACULTY OF INFORMATION SECURITY AND COMPUTER TECHNOLOGIES, SAINT-PETERSBURG NATIONAL RESEARCH UNIVERSITY OF INFORMATION TECHNOLOGIES, MECHANICS AND OPTICS, SAINT PETERSBURG
Abstract: high speed is very important for 99% of our applications. This is especially true for the mobile platforms, where processing power and, accordingly, battery power is limited. Therefore, every self-respecting developer seeks to optimize the performance of your application in order to eliminate the various delays that make up the total reaction time. If in this case we obtain the desired speed of work, then we really can gradually return the disconnected elements and see how it affects performance. Keywords: phone, application, network, server, battery, user.
ОПТИМИЗАЦИЯ СЕТИ В РАЗРАБОТКЕ МОБИЛЬНЫХ
ПРИЛОЖЕНИЙ Дык Б. М.1, Тхао Л. Д.2, Хиеу Л. В.3, Кхое Н. Х.4, Лам Н. Ч.5, Хыонг Л. Ч. Т. Т.6 (Российская Федерация)
1Дык Буй Минь - магистрант, кафедра программных систем, факультет инфокоммуникационных технологий; 2Тхао Ле Дык - студент, кафедра геоинформационных систем, факультет инфокоммуникационных технологий;
3Хиеу Ле Ван - студент; 4Кхое Нгуен Хыу - студент, кафедра безопасные информационные технологии, факультет информационной безопасности и компьютерных технологий; 5Лам Нгуен Чонг- студент; 6Хыонг Лыу Чан Тхи Тхьен - студент, кафедра проектирования и безопасности компьютерных систем, факультет информационной безопасности и компьютерных технологий, Санкт-Петербургский национальный исследовательский университет информационных технологий, механики и оптики, г. Санкт-Петербург
Аннотация: высокая скорость работы очень важна для 99% приложений. Особенно это актуально на мобильных платформах, где вычислительные мощности и, соответственно, заряд аккумулятора весьма ограничены. Поэтому каждый уважающий себя разработчик стремится оптимизировать работу своего приложения с целью устранения различных задержек, из которых складывается общее время реакции. Если в этом случае мы получаем желаемую скорость работы,
то дальше можно потихоньку возвращать отключенные элементы и смотреть, как это влияет на производительность.
Ключевые слова: телефон, приложение, сеть, сервер, аккумулятор, пользователь.
It's very important for our applications to stay up to date in order to give the latest social feeds, news, and weather reports to your users. But in reality, syncing too often can be the worst idea for the performance of your application. There's one hard and fast rule when it comes to syncing your data over the network. Do not over sync. I mean, it's a pretty common situation. The user has your app active, or maybe it was the last app they used. And you want to make sure that there's plenty of new data available for them, so they won't close your app or let their attention wander elsewhere. So you sync a lot. You ping the server. You ask for new data and bring it down as often as you can. But let's face it, this is a horrible idea. Firstly, this destroys the user's battery, and as we've said before, networking is the single biggest battery hog there is not only does it drain battery just to initialize the chip, but then it keeps it awake for an additional 20 to 60 seconds after you're done with your request, also drawing power.
In fact, you can fall into a really bad place where each one of your networking requests ends up waking up the radio and paying this cost. Secondly, consider the sheer volume of bits that your app is now responsible for requesting on the user's phone. For users on restricted-usage data plans this can be a make or break crime. I mean, one app eating up a month's worth of bandwidth simply because it keeps pinging the server for new data? It's not a good idea. And this is also a double whammy because the slower the connection the longer the radio stays on to help transfer data, meaning that you're not only being taxed for bits on the wire, but also draining more battery as a result. So syncing too often is bad. But let's be realistic here. Your app needs the data in order to provide the user with the best experience. We can't just cut syncing out completely. And the truth is you don't have to. There's a few handy tricks that you can employ which will give the user the same sense of functionality but require much fewer requests [1].
The key to this solution is understanding the difference between stuff that has to happen right now and stuff that could be delayed. Now, for example, if the user takes an action requesting that their news feed updates right now, then you pretty much have to kick off that request. But really, the second and third types are where you can actually start improving performance. The requests that happen on regular intervals that keep things up to date but don't need to happen right this second. If it's not super important right now, then you can be smarter about how it's synced. Case in point, you should really never pull the server regularly for updates. You're basically just wasting bandwidth and battery for the server to tell you that nothing's changed. Instead, it's better to leverage other services, like Google Cloud Messaging, which will let the server signal the app when there's new content. This will reduce the amount of battery churn the phone is doing and reduce the overall number of server responses that you need to worry about. Now, if there's a situation where you simply have to sync, then make sure that you're not doing it on regular intervals.
Now, remember this wastes resources. And most of the time there won't be new content waiting for you. Instead, adopt a back-off pattern based on responses. For instance, if no new data is available, double the length you wait until you check again. And if nothing's available the next time, double your wait length again. This will still allow you to sync against the data but will slowly back away from higher activity based on how frequent the server side information is updating. And don't forget you can also adjust seek frequency based on user activity. For example, if you can detect that the user is driving or running or if the phone has entered into sleep mode, you can make a good assumption that they won't need data at the same rate. On the other side, if you've noticed that the phone's been asleep for eight hours and suddenly starts getting moved around, then there's a good chance the user has just woken up, and it might be the right time to kick off the sync request. And finally, don't hesitate to adjust your sync
frequency based on the state of the device. Waiting for it to be plugged in or connected to Wi-Fi to do syncing helps keep the battery happy while users are out and about.
And the good news is that you can update your app to adopt these patterns without having to write a massive amount of code. GCMNetworkManager is a Google Play services API which helps to schedule network-oriented tasks and handle batching for you. This greatly simplifies the implementation of common patterns such as waiting for networking connectivity, network retries, and exponential backoff. Basically, all the good stuff you need with one single, helpful API. And if you're ever wondering how your application's using the network, make sure to check out the Networking Traffic Tool inside of Android Studio. It will easily show you the frequency of your data transfers and the amount of data transferred during each connection [2].
Список литературы /References
1. Optimizing Downloads for Efficient Network Access. [Электронный ресурс]. Режим доступа: https://developer.android.com/training/efficient-downloads/efficient-network-access.html/ (дата обращения: 10.02.2017).
2. GcmNetworkManager. [Электронный ресурс]. Режим доступа: https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmNet workManager/ (дата обращения: 09.11.2016).
Список литературы на английском языке /References in English
1. Optimizing Downloads for Efficient Network Access. [Electronic resource]. URL: https://developer.android.com/training/efficient-downloads/efficient-network-access.html/ (date of access: 10.02.2017).
2. GcmNetworkManager. [Electronic resource]. URL: https://developers.google.com/android /reference/com/google/android/gms/gcm/GcmNetworkManager/ (date of access: 09.11.2016).