怎样优化app,看Facebook怎样做

周四,Facebook Engineering blog 发表了一篇名为《Improving Facebook on Android》博文。博文从四个方面(Performance,Data
Efficiency,

Networking,Application Size)讲述了Facebook是怎样优化app保证其在不同国家不同类型Android设备上都能表现出良好性能的。

因为原文内容比較

easy理解,这里就直接给出原文。以使上边链接打不开的同学也能看到。《菜鸟成长史:http://blog.csdn.net/zjbpku

In an effort to connect the next five billion, Facebook began to shift to a mobile-first company about
two 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 the region,
network condition, or mobile device.

To help accomplish this goal, a team of product managers and engineers traveled to Africa to
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 40 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 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 that 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 are used.
We also wanted the stories in News Feed to load faster. In order to rapidly display cached content
on poor networks, we now 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 50 percent
in the six months following the trip to Africa.

Data efficiency
Next, we realized that data is extremely expensive in emerging markets, and purchasing more
data is often a laborious process. Thus, there needed to be a concerted effort to reduce data
consumption within the Facebook app. Interacting with photos is an important part of the
Facebook experience, but it takes a sizable amount of 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 25 to 35
percent compared with JPG, and 80 percent compared with PNG. This all happened without perceived?
impact on quality.The next step was 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 was used infrequently. We changed the process of loading
images to only request resolutions equivalent to the size of the viewport in which the images will
appear. Instead of loading a full image, the device only 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 for our?
caches, and fine-tuned both to minimize the evictions for images that could be accessed again.
As was the case with performance, it was important to avoid regressing our data efficiency in the
future. We built automated tests and an elaborate system that 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 50 percent
reduction in data use compared with earlier last year.

Networking
We also invested heavily in improving the efficiency and reliability of our networking stack. It was
important to implement more modern networking concepts in emerging markets because our
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 stack 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 that the
images expected to be downloaded next are prioritized in the queue and that no images are 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 90 percent over the past year.

Application size
The most popular mobile devices in Africa have little disk space available, which is a significant
barrier to installing app upgrades. This means that people in developing countries often use older
versions of the app that don’t have up-to-date features or take advantage of the improvements
described in 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 to 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 now have 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 65 percent compared with the beginning of the year.

What comes next?
Our trip to Africa really highlighted the importance of our work on mobile performance, data
efficiency, networking reliability, and application size for emerging markets. 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 have 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 our playbook to other apps, such as
Messenger and Instagram.We will continue to innovate to make the Facebook experience better in emerging?
markets, and share tools and information that can help developers build apps that work well on different
handsets, network environments, and operating systems.

注:以上英文内容来自:Facebook Code?https://code.facebook.com/posts/485459238254631/improving-facebook-on-android/

原文地址:https://www.cnblogs.com/xfgnongmin/p/10612699.html

时间: 2024-10-13 02:45:29

怎样优化app,看Facebook怎样做的相关文章

如何优化app,看Facebook如何做

周四,Facebook Engineering blog 发表了一篇名为<Improving Facebook on Android>博文.博文从四个方面(Performance,Data Efficiency, Networking,Application Size)讲述了Facebook是如何优化app保证其在不同国家不同类型Android设备上都能表现出良好性能的.由于原文内容比较 容易理解,这里就直接给出原文,以使上边链接打不开的同学也能看到.<菜鸟成长史:http://blog

看Facebook如何做设计

[译者:耿人杰 原文:Design at Facebook 作者:Luke Wroblewski] 今天在Palo Alto的总部,Facebook的设计团队分享了他们的设计理念,以及他们是如何为2.5亿用户设计产品的.特别的是,他们强调了以下几点: 要勤写代码(get your hands dirty) 尽早且频繁地分享设计(share early & often) 设计过程要从项目开始延续到结束(be there from start to finish) 不要爱上你的设计(don't fa

看 Facebook 如何以三大法宝化茧成蝶

从大学宿舍到完整生态链:Facebook 12 年发展历程 先请看一下 Facebook 的简单发展史: 2004 年,扎克伯格在大学宿舍里开发了 Facebook,很长一段时间它只是一个简单的网站.但是后来,扩展到硬件,开发了各种产品,占据了整个社交领域,至少是北美的霸主地位.Facebook 还推进了 Connectivity(全民联网计划),给发展中国家提供免费的无线网络,再到后面做 VR.AR.人工智能等现在非常火的新领域,形成了完整的生态圈. 看 Facebook 12 年的发展,我一

优化 App 的启动时间

这是一篇 WWDC 2016 Session 406 的学习笔记,从原理到实践讲述了如何优化 App 的启动时间. App 运行理论 main() 执行前发生的事 Mach-O 格式 虚拟内存基础 Mach-O 二进制的加载 理论速成 Mach-O 术语 Mach-O 是针对不同运行时可执行文件的文件类型. 文件类型: Executable: 应用的主要二进制 Dylib: 动态链接库(又称 DSO 或 DLL) Bundle: 不能被链接的 Dylib,只能在运行时使用 dlopen() 加载

WWDC2018 之 优化 App Assets Optimizing App Assets

该篇博客记录了观看WWDC Session227<Optimizing App Assets>的内容以及一些理解. 引言 该session主要讲述了使用Assets Catalog的新特性来优化App资源文件的部署. 主要从以下四个方面来进行: 压缩(Compression) 设计(Design)和生成(Production) 分类(Cataloging) 部署(Deployment) 压缩(Compression) 图片压缩是Asset Catalog的核心,也是Assets Catalog

Android优化App启动时间

原文地址:https://developer.android.com/topic/performance/vitals/launch-time 用户希望App能够快速相应和加载,应用启动缓慢会带来糟糕的用户体验,导致用户恶评,甚至会卸载你的应用. 这篇文章提供的信息能够帮助你优化应用的启动时间.首先,我们先来了解应用启动的内部原理,接下来,我们会讨论如何分析启动性能.最后,最后我们会介绍一些影响启动性能的常见问题,并会给出相应的解决办法. 应用启动原理 应用启动可以分为三种类型,冷启动,暖启动,

如何通过优化APP截图增加下载率?

很多App开发者都有一个误解:App的搜索排名高,下载量就一定会很客观,即有了排名,就会带来相应的流量.其实排名≠下载率,我们还需要通过优化截图.标题.评论这些方面来提高用户下载率.下面来看看怎么通过优化App截图来增加下载率的! App截图为什么能提高下载率 App截图是向用户展示自己App最直观的一个环节!根据应用商店的展示规则以及用户的使用习惯,用户在找到App的时候,会通过浏览截图来判断App功能.界面这些重要信息,而这也正决定着用户是否会下载App.所以,好的应用截图能给用户展示很多有

目前众多企业站长在优化网站时最喜欢做的一项优化

网站锚文本是企业站长最熟悉不过的了,锚文本属于内链的一种表现形式,是目前众多企业站长在优化网站时最喜欢做的一项优化,很多站长也是重视锚文字的优化,但有些时候站长如果没有控制好锚文字可能会带来降权.K站等.从当前的数据显示,大部分的企业企业站长在优化网站的时候,都认为锚文字如果优化得当就会给关键词带来排名给网站带来权重,当然内链形式的锚文本比外链形式的锚文本要好控制的多,而且只要控制好站内锚文本就会给网站带来好处.因此,站内锚文本越来越让企业站长关注,特别是一些刚入行的新手站长. 这段时间笔者在自

MVC 5 App 通过 Facebook OAuth2 登陆(Sign-on)的问题

今天做了下MVC 5 App通过Google, Twitter, Linkedin 和 Facebook进行登录的例子, 算是对Asp.net Identity的一个入门,做的过程中发现了如下的问题, 通过google找到了具体的解决办法. 问题是做好相应Facebook App及Asp.net App配置之后,按Ctrol + F5运行站点,通过Facebook输入登陆帐户登陆后,页面冒红抛出异常, 异常信息如下: System.NullReferenceException: Object r