How to optimize your app to see how Facebook does it

Source: Internet
Author: User

In Thursday, Facebook Engineering blog published a blog post called "Improving Facebook on Android". Blog from four aspects (Performance,data efficiency,

Networking,application Size) tells how Facebook is optimizing apps to ensure that it performs well on different types of Android devices in different countries. Due to the comparison of the original content

Easy to understand, here directly to the original text, so that the top link can not open the classmate will also be able to see. "Rookie growth History: Http://blog.csdn.net/zjbpku"

In an effort to connect the next five billion, Facebook began to shift to a mobile-first company about
Years ago. We trained hundreds of employees on mobile development, restructured internal
Teams to build for all platforms, and moved to a fast-paced release cycle.

However, our mission extends far beyond building and delivering the best experience on high-end
Smartphones and LTE networks. We want Facebook to work for everyone–no matter,
Network condition, or mobile device.

To the accomplish this goal, a team of product managers and engineers traveled to Africa
Examine mobile performance in developing countries. We purchased several different Android
Handsets to test the latest version of the Facebook App–and the testing process proved to be
Difficult. The combination of an intermittent, low-bandwidth network connection and a lack of
Memory space on the devices resulted in slow load times and constant crashes. We even burned
Through our monthly data plans in + minutes. We returned to our offices in Seattle, London, and
Menlo Park determined to enhance thefacebook experience on Android–and soon made major improvements
In performance, data efficiency, networking, and application size.

Performance
In terms of performance, we wanted to improve slow the start times on old devices. In the beginning,
We focused on instrumenting the startup path and understanding the bottlenecks. There was no
Silver bullet in this process–we needed to carefully identify and remove each potential bottleneck.
For example, we found this start times were slower on single-core devices because too many
Features concurrently initialized themselves on application startup. We made sure to defer these
Initializations until after startup and, in some cases, until the features is used.
We also wanted the stories in News Feed to load faster. In order to rapidly display cached content
On poor networks, we are fetch stories earlier in the process to allow more time to set up
Connections and download News Feed. The cold start path has been automated to ensure that we
Prevent further regressions in these areas. These changes reduced start times by more than percent
In the six months following the trips to Africa.

Data Efficiency
Next, we realized that data are extremely expensive in emerging, and purchasing more
Data is often a laborious process. Thus, there needed to is a concerted effort to reduce data
Consumption within the Facebook app. Interacting with photos are an important part of the
Facebook experience, but it takes a sizable amount of the data to download them. If we could
Optimize the download size, we could improve data savings and perceived app performance.
First, we investigated the use of alternative compression formats for image transmission. We built
Tools to evaluate the impact of several different compression formats on data sizes and eventually
Settled on WebP. It offered both great compression performance and efficient support from
Android. The use of WebP for transmitting Facebook images resulted in data savings of 35
Percent compared with JPG, and percent compared with PNG. This all happened without perceived
Impact on quality. The next step is to work on loading images at a resolution that devices had the
Ability to handle. In the past, we loaded images at maximum resolution to allow for the zoom-in feature.
However,on These kinds of devices this feature is used infrequently. We changed the process of loading
Images to only request resolutions equivalent to the size of the viewport in which the images would
Appear. Instead of loading a full image, the device is loads the image it needs to show (such as
A thumbnail, preview, or full image at lower resolution). Of course, if someone wants to zoom-in
On an image, we then download a higher resolution image. Finally, we looked over the process used to
Cache and reuse images. We tested a number of potential caching strategies, as well as sizes
Caches, and fine-tuned both to minimize the evictions for images that could be accessed again.
As is the case with performance, it is important to avoid regressing we data efficiency in the
Future. We built automated tests and an elaborate system, can attribute data usage to
Individual features. This allows Facebook features to understand their data usage in production
And make adjustments if it increases unexpectedly. The work on data efficiency resulted in a percent
Reduction in data is compared with earlier.

Networking
We also invested heavily in improving the efficiency and reliability of our networking stack. It was
Important to implement and modern networking concepts in emerging
Stacks struggled to perform in regions with intermittent networks.
Facebook was an early adopter of OkHttp, a networking stack open-sourced by Square, and it ' s
Now the stacks used by the Android app. OkHttp allows us-to-support fast retries for intermittent
Network situations, take advantage of the SPDY protocol for faster concurrent network
Transmissions, and enable powerful instrumentation across the networking stack.
After switching to OkHttp, it became a goal to decrease the number of reports regarding failed
Image loads in News Feed. We fine-tuned our image pre-fetching algorithms and altered the
Process through which we queue images for download. The process now ensures the
Images expected to be downloaded next is prioritized in the queue and that no images is stuck
In the queue for too long. In combination with better data usage for images, reports of slow or failed
Image loads dropped by almost-percent over the past year.

Application Size
The most popular mobile devices in Africa has little disk space available, which is a significant
Barrier to installing app upgrades. This means, people in developing countries often use older
Versions of the app that don ' t has up-to-date features or take advantage of the improvements
Described in the This blog post. Our colleagues in the Facebook London office focused on improving app
Size efficiency. They approached this problem by utilizing Google Play ' s ability to upload multiple
APKs for different Android OSes and screen resolutions. This allows us-exclude excess code for features or
Resources not supported on certain mobile devices. As with the other areas, instrumentation and testability
were important to making sure we could bring the app size down. We are now having tools that calculate how
Each feature contributes to app size and analyze device size regressions. In the end, the app size has
been reduced by + percent compared with the beginning of the year.

What comes next?
Our trips to Africa really highlighted the importance of we work on mobile performance, data
Efficiency, networking reliability, and application size for emerging. We ' ve made a
Concerted effort to improve in all these areas and achieved a significant amount of success in the
Past year.
The lessons learned has already impacted the development of new features. We Test All major
Features and changes in poor networking scenarios. We have automated verification for various
Performance and efficiency characteristics, which allows the features team to receive immediate
Feedback on the impact of their code. We also expanded playbook to other apps, such as
Messenger and Instagram.we would continue to innovate to make the Facebook experience better in emerging
and share tools and information that can help developers build apps the work well on different
Handsets, network environments, and operating systems.


Note: The above English content is from: Facebook Code Https://code.facebook.com/posts/485459238254631/improving-facebook-on-android/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.