城市天际线下载
不同角度的软件工程 (Software Engineering in different perspectives)
In the last few months, I have been exploring and experiencing (a.k.a playing) Cities: Skylines. For those who are not aware, Cities: Skyline is a simulated city-building video game. Although this game focuses on city planning, I found it interestingly sharing similar problems to what we deal with in Software Engineering.
在过去的几个月中,我一直在探索和体验(又称“玩耍”)“ 城市:天际线” 。 对于那些不知道的人,《 城市:天际线》是一款模拟城市建筑的视频游戏。 尽管该游戏专注于城市规划,但我发现它有趣地与我们在软件工程中遇到的问题共享相似的问题。
In this article, we would be looking at Traffic, the similarities in its impacts, and approaches to solve the problems in both City Planning and Software Engineering. These problems arise due to handling high load while having resource constraints.
Let me show you how. But, please bear in mind that my knowledge with city planning is limited to exposure to the game and personal casual life experiences.
让我告诉你怎么做。 但是,请记住,我对 城市规划的 知识 仅限于接触游戏和个人休闲生活。
交通 (Traffic)
Traffic unarguably is one of the biggest issues in Cities: Skylines or any cities in the world. The longer the time to get from A to B, the less efficient things can be run in a city.
毫无疑问,交通是城市中最大的问题之一:天际线或世界上任何城市。 从A到B的时间越长,在城市中运行的效率越低。
Let’s take the Economy and Healthcare aspects as examples.
让我们以经济和医疗保健方面为例。
对经济的影响 (Impacts on the Economy)
If traffic is bad, raw materials cannot be transported in time. This leads to goods that cannot be produced in time. Commercials do not have enough to sell. People do not have enough to buy and consume. The economy collapses.
如果交通不畅,原材料将无法及时运输。 这导致无法及时生产商品。 商业广告没有足够的销量。 人们没有足够的购买和消费。 经济崩溃。
People start leaving the city. POOFS, the city is gone.
人们开始离开这座城市。 POOFS,这座城市不见了。
对医疗保健的影响 (Impacts on Healthcare)
If traffic is bad, it takes longer for ambulances to travel from hospitals to patients and get back. With a limited number of ambulances, longer round trip time means fewer people can reach hospitals.
如果交通不畅,救护车需要更长的时间才能从医院运送到病人并返回。 由于救护车数量有限,往返时间较长,意味着到医院就医的人数会减少。
Imagine there are 10 ambulances in a hospital. If all of them are stuck in traffic jams, no patient would be treated in time.
想象一下,医院里有10辆救护车。 如果所有这些人都被塞在交通拥堵中,则不会及时治疗患者。
Or about deathcare, there are a limited number of hearses in each funeral company to transport the deads. If all of the hearses are stuck in traffic or take a long time to collect the dead, eventually, there would be enough dead bodies lying in buildings making the city unlivable.
关于死亡护理 ,每个fun仪公司都有数量有限的灵车来运送死者。 如果所有的灵车都堵在车里或花费很长时间来收集死者,那么最终,建筑物中就会有足够多的死者尸体,使这座城市无法居住。
People start leaving the city. POOFS, the city is gone.
人们开始离开这座城市。 POOFS,这座城市不见了。
软件工程中的流量问题 (Traffic problems in Software Engineering)
The same challenge applies to software applications too.
同样的挑战也适用于软件应用程序。
The higher the latency in network calls resulted in longer response time to end-users’ requests. Given a limited number of concurrent requests can be served, fewer requests can be handled, and the service would eventually reach denial-of-service (DoS).
络呼叫的等待时间较长,导致对最终用户请求的响应时间更长。 如果可以处理有限数量的并发请求,则可以处理更少的请求,并且该服务最终将达到拒绝服务(DoS)。
解决交通问题 (Solving the traffic issues)
There is quite a number of patterns we could apply from Software Design into City Planning.
从软件设计到城市规划,我们可以应用许多模式。
But first, to solve traffic problems, we would first need to
但是首先,要解决交通问题,我们首先需要
- Understand where traffic comes from
了解流量来自何处
- Identify hot spots
识别热点
- And then solve the problems
然后解决问题
Let’s start!
开始吧!
在城市规划中 (In city planning)
Traffic comes from people going to work or going for entertainment.
交通来自上班或娱乐的人们。
Traffic comes from trucks transporting raw materials to industrial zones, transporting goods from industrial zones to commercial zones.
交通来自将原材料运输到工业区,将货物从工业区运输到商业区的卡车。
Traffic comes from public services like healthcare, deathcare, firetrucks, police cars, …
交通来自医疗保健,死亡护理,救火车,警车等公共服务。
在软件工程中 (In software engineering)
Traffic comes from users requesting for webpages, APIs, videos, images, …
流量来自请求 页,API,视频,图像等的用户。
Traffic comes from analytics trackings.
流量来自分析跟踪。
In the context of microservices, besides traffic originated from end-users, there is a large amount of internal traffic happening due to communication between services.
在微服务的上下文中,除了源于最终用户的流量之外,由于服务之间的通信,还会发生大量内部流量 。
识别热点 (Identify hot spots)
I love making data-driven decisions.
我喜欢制定数据驱动型决策。
It is pretty awesome that Cities: Skylines provides a set of tools for that. You can get more tooling from the modding workshops too.
城市:天际线为此提供了一套工具,这真是太棒了。 您也可以从改装车间获得更多工具。
Looking at the traffic analyzer, we would be able to identify the hot spots that need looking at. Most of the time, they would be industrial or commercial areas where a lot of trucks operating.
查看流量分析器,我们将能够确定需要查看的热点。 在大多数情况下,它们将是在许多卡车在运转的工业或商业 区域 。
You can observe a lot of red areas around intersections, those are places vehicles making turns to their destinations. This means that, if there are a lot of vehicles going to the same destinations, making the same turns, traffic would be bad.
您可以在十字路口周围看到很多红色区域,这些区域是车辆驶向目的地的地方。 这意味着,如果有许多车辆前往相同的目的地,进行相同的转弯,那么交通将会很糟糕。
In software development
在软件开发中
Great toolings would also help make our lives easier.
出色的工具也将使我们的生活更轻松。
It is crucial to have your endpoints and system metrics monitored. Some of the common tools are SignalFx, Datadog, Prometheus, …
监视端点和系统指标至关重要。 一些常见的工具是SignalFx,Datadog,Prometheus等。
Monitoring would help to identify long-running requests or detect sudden spikes in traffic.
监视将有助于识别长时间运行的请求或检测流量突然增加。
Now let’s talk about some of the ways to solve the traffic problems.
现在让我们讨论一些解决交通问题的方法。
公共交通与批量请求 (Public transport vs. Batch requests)
A bus can transport around 30 people. A metro train can transport around 150 people.
一辆公共汽车可以运送大约30人。 地铁可运送约150人。
Without public transport, those 30–150 people using private vehicles would result in 15–50 times more traffic than a single bus or train.
如果没有公共交通工具,那30-150人使用私家车将导致的交通量是单辆巴士或火车的15-50倍 。
In software engineering, a similar strategy is applied by batching network requests in larger batch requests. Each request has its own request headers and response headers. Batching requests help minimize bandwidth consumption thanks to avoiding the headers of each individual request.
在软件工程中 ,通过在较大的批处理请求中批处理 络请求来应用类似的策略。 每个请求都有其自己的请求标头和响应标头。 批处理请求避免了每个单独请求的标头,从而有助于最大程度地减少带宽消耗。
It would also help significantly reduce the number of IO calls, i.e. reduce latencies when communicating between services.
这也将有助于大大减少IO调用的数量,即减少服务之间进行通信时的等待时间。
划分高流量区域与分片 (Dividing high traffic zones vs. Sharding)
As explained above, industrial zones are major sources of traffic due to several reasons
- Trucks delivering raw materials to factories
卡车运送原料到工厂
- Trucks delivering produced goods from factories to commercial zones
卡车将生产的货物从工厂运送到商业区
- Private vehicles of people coming for work
上班族的私家车
- Public services (especially firetrucks as factories being highly prone to fire)
公共服务(尤其是因为工厂极易起火的救火车)
- And, trucks are significantly bigger than normal vehicles, occupy more space when queuing, and take a longer time to turn or accelerate
而且,卡车比普通车辆大得多,排队时占用更多空间,而且转弯或加速所需的时间更长
Therefore, large industrial zones easily cause traffic jams on the main roads in-and-out the areas since even 5-lane-road would not be sufficient to handle such traffic.
因此,大型工业区很容易在该区域内外的主要道路上造成交通拥堵,因为即使是5车道的道路也不足以处理此类交通。
One of the approaches to this problem is “Sharding”.
其中一个办法解决这个问题的是“ 拆分 ”。
“Sharding” means dividing large industrial zones into small distributed industrial zones. This would significantly reduce the load on the main roads leading into or leading out of the zones.
“ 拆分 ”是指将大型工业区分成小的分布式工业区。 这将显着减少通往区域的主要道路的负荷。
在软件工程中 (In software engineering)
Sharding is used to divide giant data sets into smaller distributed data sets. It’s a popular technique in database optimization.
拆分是用来划分巨大的数据集分成更小的分布式数据集。 这是数据库优化中的流行技术。
组件的专用资源和路由 (Dedicated resources and routings for components)
Let’s revisit the ambulance example. The last thing you would like to is for AMBULANCES to be stuck in traffic with TRUCKS as they are serving different “stakeholders”. Ambulances serve residentials, trucks do not.
让我们回顾一下救护车的例子。 您最后要做的就是让AMBULANCES与TRUCKS保持联系,因为它们服务于不同的“利益相关者”。 救护车服务于住宅,卡车则不服务。
It seems to be common sense to mix between residential areas and commercials areas. However, traffic would easily be mixed up between the two.
在住宅区和商业区之间混合似乎是常识。 但是,流量很容易在两者之间混合。
It is more efficient to split residential, commercial, and industrial zones to its own areas. Each of these zones would need dedicated roads leading from highways to them.
将住宅,商业和工业区划分为自己的区域效率更高。 这些区域中的每个区域都需要从高速公路通向它们的专用道路 。
在软件工程中 (In software engineering)
Similarly in software, it is not desirable for traffic from analytics collectors or asset serving to affect core Web/API servers.
类似地,在软件中,来自分析收集器的流量或资产服务影响核心Web / API服务器也是不希望的。
Therefore, in practices, different domains are used for each of them to maximize browser concurrency since browsers limit concurrency per domain.
因此,在实践中,由于浏览器限制每个域的并发性,因此对每个域使用不同的域以最大化浏览器的并发性。
Different sets of servers are also used for each of the purposes. Web/API servers would be separated from Analytics collection servers. Assets would usually utilize CDN to optimize both delivery speed and traffic.
每种目的还可以使用不同组的服务器 。 Web / API服务器将与Analytics收集服务器分开。 资产通常会利用CDN来优化投放速度和流量。
结论 (Conclusion)
Those are just some of the aspects that I find interesting similar between City planning and Software design. What do you think about it would like to hear your thoughts.
这些只是我发现城市规划和软件设计之间相似的一些方面。 你怎么看待这件事想听听你的想法。
Thanks for reading!
谢谢阅读!
翻译自: https://medium.com/swlh/cities-skylines-from-a-software-engineers-point-of-view-709d75229b86
城市天际线下载
文章知识点与官方知识档案匹配,可进一步学习相关知识Python入门技能树人工智能机器学习工具包Scikit-learn213201 人正在系统学习中 相关资源:典型自动驾驶仿真软件介绍-iatf16949标准知识培训讲义-交通文档类…
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!