<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chiyu Zhong on Medium]]></title>
        <description><![CDATA[Stories by Chiyu Zhong on Medium]]></description>
        <link>https://medium.com/@zhongchiyu?source=rss-38277d9461f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g36FpM1gyv7toLwYzIYUUw@2x.jpeg</url>
            <title>Stories by Chiyu Zhong on Medium</title>
            <link>https://medium.com/@zhongchiyu?source=rss-38277d9461f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:49:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zhongchiyu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Lies, Damned Lies, and Service Benchmarks]]></title>
            <link>https://code.tubitv.com/lies-damned-lies-and-service-benchmarks-b1fe4ee5940?source=rss-38277d9461f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1fe4ee5940</guid>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[akka]]></category>
            <category><![CDATA[scala]]></category>
            <dc:creator><![CDATA[Chiyu Zhong]]></dc:creator>
            <pubDate>Tue, 21 Jan 2020 20:01:01 GMT</pubDate>
            <atom:updated>2020-01-21T20:01:01.783Z</atom:updated>
            <content:encoded><![CDATA[<p>Tubi streams thousands of free movies and TV shows to our users. Because we have such an extensive movie and TV content catalog, personalized recommendations are essential to the core user experience. Our personalization models are served in real-time to millions of users. To support our real-time model serving requirements, we built a backend service that would compute recommendations upon a user landing on the Tubi home screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*YHzmvGKSwdXJp_Q_1lvrxQ.png" /></figure><p>The models and features needed by this service are ingested via a machine learning pipeline that defines the boundary between our ML modeling and platform teams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Blep8dqqbJrR1RfIImuXAg.png" /><figcaption>The relationship between real-time service, offline service, and offline pipeline</figcaption></figure><p>Computing and serving online recommendations is a challenging task but necessary to improve user experience. Unlike pre-computed rankings that can be looked up from a database, the real-time service has to consume memory and CPU, both finite resources, to actually compute the recommendations on-demand. And because we want to offer our users a smooth interactive experience, we put heavy emphasis on making sure the performance is top-notch. This blog post describes how we benchmark backend service to make sure it matches our latency and throughput requirements.</p><h3>Microbenchmark</h3><p>Microbenchmark is a benchmark designed to measure the performance of a very small and specific piece of code.</p><p>As a baseline, we wanted to get a sense of the core model computation time before starting to implement the backend service. For example, if computing a single recommendation takes several hundred milliseconds, then it means our overall turnaround time will have <a href="https://www.tactuallabs.com/papers/howMuchFasterIsFastEnoughCHI15.pdf">noticeable latency</a> to the user.</p><p>We use <a href="http://scalametr.github.io/">ScalaMeter</a> to microbenchmark model execution performance,</p><pre>val sizes = Gen.range(&quot;size&quot;)(1000, 10000, 1000)<br>val input = for { size &lt;- sizes } yield genRows(size)</pre><pre>performance of &quot;RealTimeModelServing&quot; in {<br>  measure method &quot;predict&quot; in {<br>    using(input) in { rows =&gt;<br>      rows.map(predictor.predict)<br>    }<br>  }<br>}</pre><p>The benchmark code is pretty simple, we generate random input rows with size from 1,000 to 10,000 (i.e., the number of movies/shows that need to be ranked) then execute the model.</p><p>This is the benchmark output</p><pre>Sampling 4 measurements in separate JVM invocation 8 - RealTimeModelServing.predict, Test-0.<br>Finished test set for RealTimeModelServing.predict, curve Test-0<br>:::Summary of regression test results - Accepter():::<br>Test group: RealTimeModelServing.predict<br>- RealTimeModelServing.predict.Test-0 measurements:<br>  - at size -&gt; 1000: passed<br>    (mean = 23.57 ms, ci = &lt;20.66 ms, 26.47 ms&gt;, significance = 1.0E-10)<br>  - at size -&gt; 2000: passed<br>    (mean = 44.48 ms, ci = &lt;40.30 ms, 48.66 ms&gt;, significance = 1.0E-10)<br>  - at size -&gt; 3000: passed<br>...<br>  - at size -&gt; 9000: passed<br>    (mean = 195.98 ms, ci = &lt;185.69 ms, 206.27 ms&gt;, significance = 1.0E-10)<br>  - at size -&gt; 10000: passed<br>    (mean = 222.22 ms, ci = &lt;197.03 ms, 247.41 ms&gt;, significance = 1.0E-10)</pre><p>The benchmark result shows that, on average, 1,000 rows input takes 23.57ms. The initial result, without much optimization, looks promising; we can thus start implementing a proof of concept backend service.</p><h3>Load Testing</h3><p>Once the service code has been implemented, it is time to evaluate the overall performance, from accepting, validating and parsing the request to eventually returning a result.</p><p>Load testing simulates multiple users accessing the service, to see how fast service can respond under stress.</p><p><strong>Basics</strong></p><p>Three load testing metrics can be used to describe the performance and correctness of the service</p><ul><li><strong>Latency</strong> is how fast a service responds to the client, typically measured in milliseconds, instead of using average, latency usually measured in <strong>percentiles</strong>, 99 percentiles is 100ms means 99% of the request returned within 100ms, it also described as p99</li><li><strong>Throughput</strong> is how many requests a service can process in a certain amount of time, usually measured as <strong>requests per second</strong></li><li><strong>Error Rate</strong> is how many requests failed in a certain amount of time, it describes the correctness of the service under load</li></ul><p>These metrics can affect each other, higher throughput typically means higher latency and higher error rate.</p><p>Besides latency, throughput, and error rate, we should also monitor host resources (CPU, memory, etc) during load testing. Ideally, we want to build a service that satisfies throughput and latency requirements while incurring the least amount of infrastructure cost.</p><p><strong>Plan</strong></p><p>With the above metrics in mind, general load testing includes the following steps</p><ol><li>define service throughput, latency, and error rate requirements</li><li>send traffic to warm-up target service</li><li>send load testing traffic to target service, record throughput, latency, error rate, and server resource metrics</li><li>gradually increase load</li><li>based on recorded metrics, decide if the service matches our requirements, what’s the maximum service capacity, and which instance type is suitable for the service</li></ol><p><strong>Test</strong></p><p>There are many open-source software available for load testing, take a look at <a href="https://github.com/denji/awesome-http-benchmark">awesome-http-benchmark</a> repo to see which one fits your requirements.</p><p>We used <a href="https://github.com/giltene/wrk2">wrk2</a> to load testing the service. Wrk2 is a modified version of <a href="https://github.com/wg/wrk">wrk</a>, it adds a ` — rate` option to specify a throughput argument. The main difference between the two is described by <a href="https://github.com/wg">Will Glozer</a> in <a href="https://github.com/wg/wrk/issues/323">https://github.com/wg/wrk/issues/323</a>, the key takeaway is:</p><blockquote>“the naming of “wrk2” is unfortunate, it’s evolved into a very different tool based on generating load at a constant rate and can only record latencies at millisecond granularity. Whereas wrk generates load as fast as possible and tracks latency at the microsecond level.”</blockquote><p>Generating load at a constant rate is important as it aids in avoiding coordinated omission, a common pitfall in high throughput, low latency scenarios, when the load generator and the service being tested inadvertently end up coordinating end omitting high latency behavior the service may normally exhibit under load. For more information, check out <a href="https://www.youtube.com/watch?v=lJ8ydIuPFeU">“How NOT to Measure Latency” by Gil Tene</a>.</p><p>For our expected use cases, the real-time model service should be able to process at least 400 requests per second, with a p99 of less than 200ms and error rate less than 0.1%.</p><p>We deployed the POC service to a single AWS EC2 instance with type c5.2xlarge, and started with a rate of 100 requests per second.</p><p>The load test results at 100 requests per second are shown below:</p><pre>$ wrk --rate 100 --duration 5m --latency --u_latency --threads 8 --connections 16 --script wrk.lua <a href="http://predictor-02/">http://predictor-02</a><br>.node.tubi:8080/predictor/v1/get-ranking<br>...<br>  Latency Distribution (HdrHistogram - Recorded Latency)<br> 50.000%   74.43ms<br> 75.000%   87.42ms<br> 90.000%   95.36ms<br> 99.000%  108.42ms<br> 99.900%  120.77ms<br> 99.990%  126.01ms<br> 99.999%  129.21ms<br>100.000%  129.21ms<br>...<br>  Latency Distribution (HdrHistogram - Uncorrected Latency (measured without taking delayed starts into account))<br> 50.000%   73.73ms<br> 75.000%   86.78ms<br> 90.000%   94.65ms<br> 99.000%  107.65ms<br> 99.900%  120.45ms<br> 99.990%  125.76ms<br> 99.999%  128.83ms<br>100.000%  128.83ms<br>...<br>  30000 requests in 5.00m, 199.19MB read<br>  Non-2xx or 3xx responses: 4055<br>Requests/sec:     99.99<br>Transfer/sec:    679.83KB</pre><p>Load test at 150 requests per seconds:</p><pre>$ wrk --rate 150 --duration 5m --latency --u_latency --threads 8 --connections 16 --script wrk.lua <a href="http://predictor-02/">http://predictor-02</a><br>.node.tubi:8080/predictor/v1/get-ranking<br>…<br>  Latency Distribution (HdrHistogram - Recorded Latency)<br> 50.000%   73.73ms<br> 75.000%   87.49ms<br> 90.000%   95.81ms<br> 99.000%  111.42ms<br> 99.900%  130.43ms<br> 99.990%  152.19ms<br> 99.999%  184.70ms<br>100.000%  184.70ms<br>...<br>  Latency Distribution (HdrHistogram - Uncorrected Latency (measured without taking delayed starts into account))<br> 50.000%   72.96ms<br> 75.000%   86.65ms<br> 90.000%   94.97ms<br> 99.000%  110.33ms<br> 99.900%  129.28ms<br> 99.990%  151.29ms<br> 99.999%  183.81ms<br>100.000%  183.81ms<br>...<br>  45008 requests in 5.00m, 297.60MB read<br>  Non-2xx or 3xx responses: 6207<br>Requests/sec:    150.02<br>Transfer/sec:      0.99MB</pre><p>Load test at 200 requests per second:</p><pre>$ wrk --rate 200 --duration 5m --latency --u_latency --threads 8 --connections 16 --script wrk.lua <a href="http://predictor-02/">http://predictor-02</a><br>.node.tubi:8080/predictor/v1/get-ranking<br>...<br>  Latency Distribution (HdrHistogram - Recorded Latency)<br> 50.000%    6.20s<br> 75.000%    8.45s<br> 90.000%    9.91s<br> 99.000%   11.49s<br> 99.900%   11.78s<br> 99.990%   11.95s<br> 99.999%   11.98s<br>100.000%   11.99s<br>...<br> Latency Distribution (HdrHistogram - Uncorrected Latency (measured without taking delayed starts into account))<br> 50.000%   85.63ms<br> 75.000%   98.88ms<br> 90.000%  111.49ms<br> 99.000%  136.57ms<br> 99.900%  156.29ms<br> 99.990%  172.67ms<br> 99.999%  180.10ms<br>100.000%  183.42ms<br>...<br>  57662 requests in 5.00m, 380.75MB read<br>  Non-2xx or 3xx responses: 8043<br>Requests/sec:    192.20<br>Transfer/sec:      1.27MB</pre><p>As the results show, at 200 requests per second, the p99 increased a lot.</p><p>Because the real-time model service is a CPU intensive application, we use <a href="http://www.brendangregg.com/usemethod.html">the USE method</a> and `vmstat 1` to verify that CPU usage is at saturation and the true reason we can not handle this load. This is an important verification step to make sure we are not hitting any other bottlenecks.</p><h3>Multi-host test</h3><p>One of the fundamental guidelines of building scalable services is to design with the ability for a service to horizontally scale. That means that adding more resources, in our case machines, should yield an approximately linear improvement in performance. To verify that, we conduct a multi-host test. After scaling out the service to 4 nodes, we also need to modify the wrk2 benchmark script to distribute traffic to multiple hosts.</p><pre>-- usage `wrk --latency -c 8 -t 4 -d 1m -R 300 -s wrk.lua <a href="http://predictor.service.tubi:8080/predictor/v1/get-ranking%60">http://predictor.service.tubi:8080/predictor/v1/get-ranking`</a><br>-- note the number of thread should equal to or larger than the number of host<br>local addrs = wrk.lookup(wrk.host, wrk.port or &quot;http&quot;)<br>for i = #addrs, 1, -1 do<br>    if not wrk.connect(addrs[i]) then<br>        table.remove(addrs, i)<br>    end<br>end<br>local index = 0</pre><pre>function setup(thread)<br>    index = index + 1<br>    thread.addr = addrs[index]<br>end</pre><pre>function init(args)<br>   local msg = &quot;thread addr: %s&quot;<br>   print(msg:format(wrk.thread.addr))<br>end</pre><p>The benchmark result shows that after scaling out, the service can easily handle the traffic of 400 requests per second.</p><pre>$ wrk --rate 200 --duration 5m --latency --threads 8 --connections 16 --script wrk.lua http://<br>predictor.service.tubi:8080/predictor/v1/get-ranking<br>...<br>  Latency Distribution (HdrHistogram - Recorded Latency)<br> 50.000%   35.94ms<br> 75.000%   39.23ms<br> 90.000%   45.02ms<br> 99.000%   58.56ms<br> 99.900%   74.05ms<br> 99.990%   89.02ms<br> 99.999%   96.13ms<br>100.000%  161.02ms<br>...<br>  59999 requests in 5.00m, 396.19MB read<br>  Non-2xx or 3xx responses: 8363<br>Requests/sec:    200.04<br>Transfer/sec:      1.32MB</pre><pre>$ wrk --rate 400 --duration 5m --latency --u_latency --threads 8 --connections 16 --script wrk.lua http://<br>predictor.service.tubi:8080/predictor/v1/get-ranking<br>...<br> Latency Distribution (HdrHistogram - Recorded Latency)<br> 50.000%   38.14ms<br> 75.000%   43.04ms<br> 90.000%   49.09ms<br> 99.000%   66.75ms<br> 99.900%   87.93ms<br> 99.990%  105.34ms<br> 99.999%  135.42ms<br>100.000%  142.34ms<br>...<br>  119980 requests in 5.00m, 792.34MB read<br>  Non-2xx or 3xx responses: 16592<br>Requests/sec:    399.99<br>Transfer/sec:      2.64MB</pre><h3>Autobench2</h3><p>To simplify the above load testing process, we wrote a single python wrapper around wrk2. The wrapper script takes care of things like warm-up, gradually increases the load and eventually generates a report that can be used to display throughput and latency graphs on web pages.</p><pre>$ autobench --verbose --connection 8 --thread 4 --duration 1m \<br>            --script wrk.lua --warmup_duration 1m --low_rate 10 \<br>            --high_rate 20 --rate_step 10 <a href="http://predictor.service.tubi:8080/predictor/v1/get-ranking">http://predictor.service.tubi:8080/predictor/v1/get-ranking</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kVQQzyndrlD5S5YYPCufQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0siH3YiLV4gAHi2xNIwEw.png" /><figcaption>Single node performance report</figcaption></figure><h3>Conclusion</h3><p>In this blog post, we explained why we need to benchmark the service, introduced microbenchmark and load-testing basics, and walked through the process of load-testing a service to find its maximum capacity. We also presented an open-source tool to simplify the benchmark process. If you are interested in building high throughput, low latency backend services at scale, <a href="https://tubitv.com/static/careers">come join Tubi!</a></p><h3>References</h3><ul><li><a href="https://en.wikipedia.org/wiki/Lies,_damned_lies,_and_statistics">Lies, damned lies, and statistics</a></li><li><a href="https://github.com/CatTail/autobench2/">Autobench2</a></li><li><a href="https://www.digitalocean.com/community/tutorials/an-introduction-to-load-testing">An Introduction to Load Testing</a></li><li><a href="https://www.mnot.net/blog/2011/05/18/http_benchmark_rules">HTTP Benchmark Rules</a></li><li><a href="https://cdn.oreillystatic.com/en/assets/1/event/122/Linux%20perf%20tools%20Presentation.pdf">Linux Performance Tools</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1fe4ee5940" width="1" height="1" alt=""><hr><p><a href="https://code.tubitv.com/lies-damned-lies-and-service-benchmarks-b1fe4ee5940">Lies, Damned Lies, and Service Benchmarks</a> was originally published in <a href="https://code.tubitv.com/">Tubi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraforming Tubi TV]]></title>
            <link>https://code.tubitv.com/terraforming-tubi-tv-fd565e4a8c9a?source=rss-38277d9461f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd565e4a8c9a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[hashicorp]]></category>
            <dc:creator><![CDATA[Chiyu Zhong]]></dc:creator>
            <pubDate>Thu, 05 Apr 2018 15:01:01 GMT</pubDate>
            <atom:updated>2018-04-05T15:01:01.078Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uk2P6KksdGSjkel0bdVsEg.png" /><figcaption>Terraform makes it easy to manage tens of thousands of infrastructure components and even <a href="https://github.com/28mm/blast-radius">visualize it</a></figcaption></figure><p>Cloud providers like AWS, Azure, etc make it extremely easy to get your product up and running quickly. At Tubi, much like other companies experiencing rapid growth, it became readily apparent to everyone that creating infrastructure resources like EC2 instances, security groups, etc manually via the API or the UI console is inefficient, unmanageable and error prone.</p><p>In this post, we will give a brief introduction to Terraform. We will examine how we used Terraform to codify thousands of different AWS resources, including hundreds of EC2 instances running our various services.</p><h3>Introduction to Terraform</h3><p>HashiCorp’s Terraform is an open source tool to write, plan and create Infrastructure as Code. Terraform uses a DSL to define infrastructure resources, automatically build a dependency graph and gives you a way to create a plan. It also lets you inspect changes prior to applying them.</p><h3>Workspaces, State and Components</h3><p>A basic notion in Terraform is that it maintains its own state. While other tools source of truth comes from inspecting your current resources via the provider’s API, Terraform uses a state file to map its own internal representation of real world resources. To make it easier to maintain multiple states, Terraform provides a container for state file management called Workspace. At Tubi, we use the Workspace feature to manage development, staging and production environments. Throughout this post, we use the terms workspace and environment interchangeably.</p><p>As the infrastructure becomes larger and larger, maintaining a single state file, even if split across development, staging and production environments, can become unwieldy and slow. Since terraform state is nothing more than a file, and workspaces are simply sugar around folders containing state files, we can split our large state into multiple different components. For example,. frontend and backend are separated as two components. Now we can combine environment and component, to give us staging frontend, production frontend, staging backend and production backend.</p><h3>Terraform at Tubi</h3><p>Armed with the ability to cleanly separate our different environments as well as break down our state into smaller components, we settled on a simple layout for our Terraform code.</p><pre>.<br>├── environments<br>│   ├── default.tfvars<br>│   ├── production.tfvars<br>│   └── staging.tfvars<br>├── components<br>│   ├── backend<br>│   ├── common<br>│   ├── frontend<br>│   └── global<br>└── modules<br>    ├── ebs-volumes<br>    ├── ec2-private-instance-cluster<br>    └── vpc</pre><p>The global component does not distinguish environments, useful for shared singleton resources like IAM roles and Route53 hosted zones. The common component is useful for defining resources that do have a staging/production environment but are typically shared by all the other components, for example defining the VPC networking layout.</p><p>The environments directory contains variable definitions for each, you guessed it, environment. In our case, we want the staging environment to be a mini replica of our production environment. So we use the .tfvar files to define things like number of instances and instance types for each service. For example, production may define 100 beefy machines for ad serving services whereas staging may have 4 small ones.</p><p>To standardize running Terraform, we have a simple python wrapper. For example, to create the production frontend infrastructure, Tubi engineers execute</p><pre>$ infra terraform --environment production frontend</pre><p>The above command will switch to the production terraform workspace, change directory to frontend component, and execute the Terraform plan stage. Essentially, with some validation steps omitted for brevity, the above command is equal to</p><pre>$ cd terraform/components/frontend<br>$ terraform workspace select production<br>$ terraform plan --var-file=../../environments/production.tfvars --out=plan_file<br>(optional) $ terraform apply --var-file=../../environments/production.tfvars plan_file</pre><p>Engineers at Tubi can then take the generated plan from plan_file and open a pull request, which is reviewed like normal code and can then apply their changes once the code is merged into master.</p><p>Terraform has made it easy for us to have separate staging and production environments that can be launched by pressing a button. In follow-up posts, we will dive deep into specifics around some of the Terraform modules we built, as well as take a look at how we use Ansible for software provisioning and deployment. If you are excited about infrastructure and automation, we are actively hiring in San Francisco and Beijing, <a href="https://tubitv.com/static/careers">drop us a line</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd565e4a8c9a" width="1" height="1" alt=""><hr><p><a href="https://code.tubitv.com/terraforming-tubi-tv-fd565e4a8c9a">Terraforming Tubi TV</a> was originally published in <a href="https://code.tubitv.com/">Tubi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[对APP应用结构的思考]]></title>
            <link>https://medium.com/@zhongchiyu/app-46d59215098d?source=rss-38277d9461f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/46d59215098d</guid>
            <dc:creator><![CDATA[Chiyu Zhong]]></dc:creator>
            <pubDate>Sun, 20 Apr 2014 14:53:04 GMT</pubDate>
            <atom:updated>2015-12-30T10:24:25.156Z</atom:updated>
            <content:encoded><![CDATA[<h4>由向上返回和向前返回造成的视图切换问题</h4><p>这几天抽空阅读了<a href="https://developer.android.com/design/index.html">Android设计规范</a>和<a href="https://developer.apple.com/library/ios/design/">IOS设计资源</a>, 主要了解两个平台设计规范和之间的区别, 主要侧重非视觉和非技术相关的内容, 侧重交互设计. (忽略视觉是因为对字体和颜色毫无感觉).</p><p>本文描述基于设计规范, 而不是基于当前普遍采用的设计风格.</p><h4>术语</h4><ul><li>向前返回按钮: Android智能机硬件返回按钮</li><li>向上返回按钮: Android应用左上角的返回按钮</li><li>硬件返回: 通过向前返回按钮触发返回事件</li><li>软件返回: 通过向上返回按钮触发返回事件</li></ul><p>注: iOS不区分向前和向上返回</p><p>IOS设计资源分为三部分, 总的来说, 内容组织混乱且又冗余</p><ul><li>iOS 7 UI Transition Guide: 主要描述如何将应用迁移到iOS7</li><li>iOS Human Interface Guidelines: 描述UI设计和iOS为应用提供的功能</li><li>UIKit User Interface Catalog: 完整列举了iOS7中的视图 (view) 和 控件 (control), 设计师只需浏览每个视图 (控件) 的第一段, 了解其作用和可更改的配置即可</li></ul><p>Android设计规范按<strong>设计远景, 视觉设计, 设计通用模式和控件</strong>组织内容, 读后收获较大.</p><h3>应用组成</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ycUE-rO_1E_TeghPdDaVeA.png" /><figcaption>图一 iOS应用组成</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*7IxUHDoZKxarHXULrShPXw.png" /><figcaption>图二 Android应用组成</figcaption></figure><h3>应用结构</h3><p>和Android应用结构的多样性相比, iOS应用结构显得更简单, 作为我更喜欢iOS简单的应用结构和可预测的导航逻辑.</p><p>下图来自Android设计规范, 然而事实上, iOS的应用结构也是这样的模型.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*NiwFsOZ-Ooel-t-3JvBfmg.png" /><figcaption>图三 应用结构</figcaption></figure><p>下面通过对<strong>顶级视图, 集合视图和详细视图</strong>中视图的切换描述应用的结构, 最后将总结整体应用结构. 在描述过程中会不断提到返回的功能, 因为这于引用结构息息相关.</p><h4>顶级视图</h4><p>在顶级视图中, Android可以通过Tabs, Spinners和Navigation drawers切换视图, 而iOS则一般使用Tab bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*tHXWDbrTIGCDGLg6BKWjKw.png" /><figcaption>Tabs (Android)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*bqTeBJ2pAlxY-1zlqQNfWA.png" /><figcaption>Spinners (Android)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*BWPYTKVHFfUQpEqbsPTvog.png" /><figcaption>Navigation drawers (Android)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*B6jZd-A0mKrCuKXlMd0N4A.png" /><figcaption>Tab bars (iOS)</figcaption></figure><p>在Android设计规范中对Navigation drawer的交互令人困惑</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*qgafl21nyy2dW8b8P-d-kA.png" /></figure><p>用户从顶级视图进入其他视图后, 通过从左向右滑动可调用Navigation drawer. 这种交互令用户困惑, 因而很多应用在这里都不调出Navigation drawer, 甚至有的应用左滑执行返回.</p><p>在iOS中, Segmented Controls可以实现类似Tab bar的功能, 然而它并不切换视图</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*j6sPOlBXAsG_eXQ42ypA4g.png" /><figcaption>Segmented Controls (iOS)</figcaption></figure><p>上面讲到的这些控件基本不涉及返回功能, 除了Navigation drawers. 当使用Navigation drawers进入其他视图后可以通过向前返回回到顶级视图. 而进入下级视图 (如集合视图和详细视图) 时, 可以通过向上返回进入上级视图.</p><h4>集合视图</h4><p>集合视图的视图切换和顶级视图基本相同, 这里不再展开.</p><h4>详细视图</h4><p>通过顶级视图或集合视图可以进入详细视图.</p><p>Android支持在同类的详细视图之间进行切换</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*dj7PCLVn03P8--oiO6V6zg.png" /><figcaption>Swiping Between Detail Views (iOS)</figcaption></figure><p>iOS很少有应用支持在详细视图之间切换, 但也有例外</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*R8Pe1J7hpIBrpYwz3wkWkw.png" /><figcaption>Swiping Between Detail Views (iOS)</figcaption></figure><h4>总结</h4><p>因为iOS没有向上和向前返回两个按钮, 应用视图切换逻辑更为清晰. 而且Android向上返回按钮由于手指不宜触摸, 使用率较少, 用户大多使用向前返回, 出于这个原因, 当前大多应用将向前返回按钮的功能替换为向上返回.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46d59215098d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>