Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-08-31 17:33:01 +08:00
commit 744c434cfc
7 changed files with 268 additions and 202 deletions

View File

@ -0,0 +1,137 @@
[#]: collector: (lujun9972)
[#]: translator: (chenmu-kk)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12566-1.html)
[#]: subject: (9 open source tools for building a fault-tolerant system)
[#]: via: (https://opensource.com/article/19/3/tools-fault-tolerant-system)
[#]: author: (Bryant Son https://opensource.com/users/brson)
九个用来构建容错系统的开源工具
======
> 这些开源工具可以最大化延长运行时间并且在最大程度上减少问题。
![](https://img.linux.net.cn/data/attachment/album/202008/30/205036eqh1j8hhss9skf57.jpg)
我一直对 Web 开发和软件体系结构很感兴趣,因为我喜欢看到一个工作系统的宏观视图。无论是构建一个移动应用程序还是一个 Web 应用程序,都必须连接到互联网,在不同的模块中交换数据,这意味着你需要 Web 服务。
如果选择云系统作为应用程序的后端,则可以利用更强大的计算能力,因为后端服务将会在水平和垂直方向上进行扩展并编排不同的服务。但无论你是否使用云后端,建造一个灵活、稳定、快速又安全的容错系统是必不可少的。
要了解容错系统,让我们以脸书、亚马逊、谷歌和奈飞为例。数以亿计的用户会同时接入这些平台并通过对等网络和用户-服务器网络传输大量数据你可以肯定这其中还存在许多的带有不法目的的恶意用户例如黑客攻击和拒绝服务DoS攻击。即使如此这些平台无需停机也可以全年无休地运转。
虽然机器学习和智能算法是这些系统的基础,但它们实现持续的服务而不停机一分钟的事实值得称赞。它们昂贵的硬件设备和巨大的数据中心当然十分重要,但是支持服务的精密软件设计也同样重要。而且容错系统是一个构建如此精密系统的法则之一。
### 生产过程中导致错误的两种行为
这是考虑容错系统的另一种方法。当你在本地运行应用程序服务时,每件事似乎都很完美。棒极了!但当你提升服务到生产环境时,一切都会变得一团糟。在这种情况下,容错系统通过解决两个问题来提供帮助:故障停止行为和拜占庭行为。
#### 故障停止行为
故障停止行为是运行中系统突然停止运行或者系统中的某些部分发生了故障。服务器停机时间和数据库不可访问都属于此种类型。举个例子,在下图中,由于服务 2 无法访问,因此服务 1 无法与服务 2 进行通信。
![服务 2 停机导致的故障停止行为][2]
但是,如果服务之间存在网络问题,也会出现此问题,如下图所示:
![网络故障导致的故障停止行为][3]
#### 拜占庭行为
拜占庭行为是指系统在持续运行,但并没有产生预期行为(例如:错误的数据或者无效的数据)。
如果服务 2 的数据(值)已损坏则可能会发生拜占庭故障,即使服务看起来运行得很好,比如下面的例子:
![因服务损坏而导致的拜占庭故障][4]
或者,可能存在恶意的中间人在服务之间进行拦截,并注入了不需要的数据:
![恶意中间人导致的拜占庭故障][5]
无论是故障停止和拜占庭行为,都不是理想的情况,因此我们需要一些预防或修复它们的手段。这里容错系统就起作用了。以下是可以帮助你解决这些问题的 8 个开源工具。
### 构建容错系统的工具
尽管构建一个真正实用的容错系统涉及到深入的“分布式计算理论”和复杂的计算机科学原理,但有许多的软件工具(其中许多是开源软件)通过构建容错系统来减轻不良后果的影响。
#### 断路模式Hystrix 和 Resilience4j
[断路模式][6]是一种技术,它有助于在服务失败时返回准备好的虚拟回应或者简单回应。
![断路模式][7]
奈飞开源的 [Hystrix][8] 是断路模式中最流行的应用。
我之前工作过的很多家公司都在用这款出色的工具。令人意外的是,奈飞宣布将不再更新 Hystrix是的我知道了。相反奈飞建议使用另一种支持 Java 8 和函数式编程的 [Resilence4j][9] 之类的替代解决方案,或者类似于 [Adaptive Concurrency Limit][10] 的替代解决方案。
#### 负载均衡Nginx 和 HaProxy
负载均衡是分布式系统中最基本的概念之一,要想拥有一个生产质量的环境,必须有负载均衡的存在。要理解负载均衡器,首先我们需要明白冗余的概念。每个生产级的 Web 服务都有多个服务器在某个服务器宕机时提供冗余来接管和维持服务。
![负载均衡][11]
想想现代飞机:它们的双引擎提供冗余,使它们即使在一个引擎着火的情况下也能安全的着陆。(这也有助于大多数商用飞机拥有最先进的自动化系统)。但是,拥有多引擎(或者多服务器)也意味着必须存在一些调度机制在故障发生时有效地对系统进行路由。
负载均衡器是一种通过平衡多个服务节点来优化大流量事务的设备或者软件。举个例子,当数以千计的请求涌入时,负载均衡器可以作为中间层在不同的服务器间进行路由和平均分配流量。如果一台服务器宕机,负载均衡器会将请求转发给其它运行良好的服务器。
有许多可用的负载均衡器,但其中最出名的两个就是 Nginx 和 HaProxy。
[Nginx][12] 不仅仅是一个负载均衡器,它还是 HTTP 和反向代理服务器、邮件代理服务器和通用 TCP/UDP 代理服务器。Groupon、Capital One、Adobe 和 NASA 等公司都在使用它。
[HaProxy][13] 也很受欢迎,因为它是一个免费的、非常快且可靠的解决方案,它为基于 TCP 和 HTTP 的应用程序提供高可用性、负载平衡和代理。许多大型网络公司,包括 Github、Reddit、Twitter 和 Stack Overflow 都使用 HaProxy。是的Red Hat Enterprise Linux 同样支持 HaProxy 设置。
#### 参与者模型Akka
[参与者模型][14]是一种并发设计模式,当作为基本计算单位的“参与者”接收到消息时,它会分派责任。一个参与者可以创建更多的参与者,并将消息委派给他们。
[Akka][15] 是最著名的参与者模型实现之一。该框架同时支持基于 JVM 的 Java 和 Scala。
#### 使用消息队列的异步、非阻塞 I/OKafka 和 RabbitMQ
多线程开发在过去很流行,但是现在已经不鼓励这种做法了,取而代之的是异步的、非阻塞的 I/O 模式。对于 Java这一点在 [EnterpriseJavaBeanEJB规范][16]中得到了明确的规定:
> “企业 bean 一定不能使用线程同步原语来同步多个实例的执行。”
>
> “企业 bean 不得试图去管理线程。企业 bean 不得试图启动、停止、挂起或恢复线程,或者去更改线程的优先级或者名称。企业 bean 不得试图管理线程组。”
如今,虽然还有其他做法,如流 API 和参与者模型,但像 [Kafka][17] 和[RabbitMQ][18] 之类的消息队列为异步和非阻塞 I/O 功能提供了开箱即用的支持,同时它们也是功能强大的开源工具,通过处理并发进程可以替代线程。
#### 其他的选择Eureka 和 Chaos Monkey
用于容错系统其它有用的工具包括奈飞的 [Eureka][19] 之类的监控工具,以及像 [Chaos Monkey][20] 这样的压力测试工具。它们旨在通过在较低环境中的测试如集成INT、质量保障QA和用户接受测试UAT来早早发现潜在问题以防止在转移到生产环境之前出现潜在问题。
你在使用什么开源工具来构建一个容错系统呢?请在评论中分享你的最爱。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/3/tools-fault-tolerant-system
作者:[Bryant Son][a]
选题:[lujun9972][b]
译者:[chenmu-kk](https://github.com/chenmu-kk)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/brson
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga (magnifying glass on computer screen, finding a bug in the code)
[2]: https://opensource.com/sites/default/files/uploads/1_errordowntimeservice.jpg (Fail-stop behavior due to Service 2 downtime)
[3]: https://opensource.com/sites/default/files/uploads/2_errordowntimenetwork.jpg (Fail-stop behavior due to network failure)
[4]: https://opensource.com/sites/default/files/uploads/3_byzantinefailuremalicious.jpg (Byzantine failure due to corrupted service)
[5]: https://opensource.com/sites/default/files/uploads/4_byzantinefailuremiddleman.jpg (Byzantine failure due to malicious middleman)
[6]: https://martinfowler.com/bliki/CircuitBreaker.html
[7]: https://opensource.com/sites/default/files/uploads/5_circuitbreakerpattern.jpg (Circuit breaker pattern)
[8]: https://github.com/Netflix/Hystrix/wiki
[9]: https://github.com/resilience4j/resilience4j
[10]: https://medium.com/@NetflixTechBlog/performance-under-load-3e6fa9a60581
[11]: https://opensource.com/sites/default/files/uploads/7_loadbalancer.jpg (Load balancer)
[12]: https://www.nginx.com
[13]: https://www.haproxy.org
[14]: https://en.wikipedia.org/wiki/Actor_model
[15]: https://akka.io
[16]: https://jcp.org/aboutJava/communityprocess/final/jsr220/index.html
[17]: https://kafka.apache.org
[18]: https://www.rabbitmq.com
[19]: https://github.com/Netflix/eureka
[20]: https://github.com/Netflix/chaosmonkey

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12567-1.html)
[#]: subject: (Glances A Versatile System Monitoring Tool for Linux Systems)
[#]: via: (https://itsfoss.com/glances/)
[#]: author: (Chinmay https://itsfoss.com/author/chinmay/)
@ -10,6 +10,8 @@
Glances多功能 Linux 系统监控工具
======
![](https://img.linux.net.cn/data/attachment/album/202008/30/212820tgdi7iou6dg6qqq2.jpg)
Linux 上最常用的[命令行进程监控工具][1]是 `top` 和它那色彩斑斓、功能丰富的表弟 [htop][2]。
要[监控 Linux 上的温度][3],可以使用 [lm-sensors][4]。同样,还有很多实用工具可以监控其他实时指标,如磁盘 I/O、网络统计等。

View File

@ -1,59 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (AI system analyzes code similarities, makes progress toward automated coding)
[#]: via: (https://www.networkworld.com/article/3570389/ai-system-analyzes-code-similarities-makes-progress-toward-automated-coding.html)
[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/)
AI system analyzes code similarities, makes progress toward automated coding
======
Researchers from Intel, MIT and Georgia Tech are working on an AI engine that can analyze code similarities to determine what code actually does, setting the stage for automated software writing.
Monsitj / Getty Images
With the rapid advances in artificial intelligence (AI), are we getting to the point when computers will be smart enough to write their own code and be done with human coders? New research suggests we might be getting closer to that milestone.
Researchers from MIT and Georgia Tech teamed with Intel to develop an AI engine, dubbed Machine Inferred Code Similarity (MISIM), that's designed to analyze software code and determine how it's similar to other code. What's most interesting is the potential for the system to learn what bits of code do, and then use that intelligence to change how software is written. Ultimately, a human could explain what it wants a software program to do, and then a machine programming (MP) system could come up with a coded app to accomplish it.
**READ MORE:** [How AI can create self-driving data centers][1]
"When fully realized, MP will enable everyone to create software by expressing their intention in whatever fashion that's best for them, whether that's code, natural language or something else," said Justin Gottschlich, principal scientist and director/founder of machine programming research at Intel, in the company's [press release][2]. "That's an audacious goal, and while there's much more work to be done, MISIM is a solid step toward it."
### How it works
Neural networks give similarity scores to snippets of code "based on the jobs they are designed to carry out," Intel explains. Two code samples may look completely different but be rated the same because they perform the same function, for example. The algorithm can then determine which code snippet is more efficient.
Primitive versions of code-similarity systems are used in plagiarism detection, for example. With MISIM, however, the algorithm looks at chunks of code and attempts to ascertain contextually whether the snippets have similar characteristics or are aiming for similar objectives. It can then offer improvements in performance, for example, or general efficiency.
What's critical with MISIM is the intent of the creator, and it marks an advancement towards intent-based programming, which could enable software to be designed based on what a non-programmer creator wants to achieve. With intent-based programming, an algorithm draws on a pool of open source code rather than relying on the traditional, manual method of compiling a series of step-like programming instructions, line-by-line, telling a computer how to do something.
"A core differentiation between MISIM and existing code-similarity systems lies in its novel context-aware semantic structure (CASS), which aims to lift out what the code actually does. Unlike other existing approaches, CASS can be configured to a specific context, allowing it to capture information that describes the code at a higher level. CASS can provide more specific insight into what the code does rather than how it does it," Intel explains.
This is accomplished without a compiler (a stage used in programming that converts human-readable code into the computer program). Conveniently, partial snippets can be executed just to see what happens in that piece of code. Plus, the system gets rid of some of the more tedious parts of software development, like line-by-line bug finding. More details are available in the group's paper ([PDF][3])
Intel says the team's MISIM system is 40-times more accurate identifying similar code than previous code similarity systems.
Heres_your_sign, a Redditor [commenting on blog coverage of MISIM][4], amusingly points out that thankfully the computers aren't writing the requirements too. That would be asking for trouble, the Redditor believes.
Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3570389/ai-system-analyzes-code-similarities-makes-progress-toward-automated-coding.html
作者:[Patrick Nelson][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Patrick-Nelson/
[b]: https://github.com/lujun9972
[1]: https://www.networkworld.com/article/3568354/how-ai-can-create-self-driving-data-centers.html
[2]: https://newsroom.intel.com/news/intel-mit-georgia-tech-machine-programming-code-similarity-system/#gs.d8qd40
[3]: https://arxiv.org/pdf/2006.05265.pdf
[4]: https://www.reddit.com/r/technology/comments/i2dxed/this_ai_could_bring_us_computers_that_can_write/
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,71 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (The power of open source during a pandemic)
[#]: via: (https://opensource.com/open-organization/20/8/power-open-source-during-pandemic)
[#]: author: (Laura Hilliger https://opensource.com/users/laurahilliger)
The power of open source during a pandemic
======
Successfully addressing shared global problems requires open source—both
principles and code—to foster innovation quickly and bridge gaps in
effective remote collaboration.
![Open source prescription.][1]
When a novel coronavirus made headlines earlier this year, the world wasn't ready. In a short period of time, we all witnessed the consequences of having a global, interconnected economy unprepared for effective global collaboration. Indeed, this pandemic shed light on the under-preparedness of a truly global economy in a hyper-connected world. We didn't pay attention to the fact that a health issue in China could have an impact on both the real estate market in North Carolina and a shoe factory in Italy. Facing a pandemic, especially one that forced such extreme social distancing, required drastic shifts—both technological and social.
Many organizations, governments, and companies realized that facing a global pandemic like COVID-19 required new tools for tracking the spread of the virus. In order to keep up with this growing threat, decision makers around the world needed effective technological solutions for both tracking and contact tracing; we needed correct, up-to-the-minute data for making the best decisions. Facing this pandemic also required non-technical organizations to become technically capable quite quickly. Organizations were forced to rapidly build new solutions and uncover new ways of working. Facing this new global problem, the world realized that the digital transformation everyone has been talking about—but delaying until they had a budget—was now more important than ever.
Moreover, as we started to advise and work with different organizations around the world, we discovered that many of them were facing similar issues. As a last minute solution, many started building not only their own custom technologies but also their own custom _organizational strategies_ for tackling this crisis. Quick but reactive approaches left many governments and organizations across the world building exactly the same solutions, often in isolation. Had they collaborated and shared what they were learning, they could have been building solutions _with_ one another.
In other words: Had they been operating more like open source communities and truly open organizations, they could have found better answers sooner.
### Building global solutions the open source way
For years, members of the open source community have been collaborating with one another on projects like these. We've been working together in remote environments since long before the pandemic hit. Our processes and policies, documented or not, have allowed us to push the technology industry forward at warp speed. In a mere 30 years, we've managed to make open source the standard for new software, and we've proven that global, remote, community-based collaboration can solve big problems.
Now the rest of the world seems to be following suit, adapting open principles and practices to create global change. By relying on the open source principles and code, we could truly build more effectively shared solutions and strategies that could help us all stop a global pandemic.
We see many examples of openness bridging collaboration gaps. The [UK Government Digital Service][2] is uniting citizens and government, helping the government to operate more effectively and efficiently. The [UNESCO Global Network of Learning Cities][3] is pushing city education policy forward, facilitating partnerships between member cities. [Greenpeace is championing open source][4], and using it to help change mindsets and behaviors surrounding the climate emergency. Other coalitions have pledged to accelerate [cooperation on a coronavirus vaccine and to share research][5], treatment, and medicines across the globe.
The world needs to shift the way it's approaching problems and continue locating solutions the open source way. Individually, this might mean becoming connection-oriented problem-solvers. We need people able to think communally, communicate asynchronously, and consider innovation iteratively. We're seeing that organizations would need to consider technologists less as tradespeople who build systems and more as experts in global collaboration, people who can make future-proof decisions on everything from data structures to personnel processes.
### A new strategy: Cross-sector social innovation
Now is the time to start building new paradigms for global collaboration and find unifying solutions to our shared problems, and one key element to doing this successfully is our ability to work together across sectors. A global pandemic needs the public sector, the private sector, and the nonprofit world to collaborate, each bringing its own expertise to a common, shared platform.
By relying on the open source principles and code, we could truly build more effectively shared solutions and strategies that could help us all stop a global pandemic.
The private sector plays a key role in building this method of collaboration by building a robust social innovation strategy that aligns with the collective problems affecting us all. This pandemic is a great example of collective global issues affecting every business around the world, and this is the reason why shared platforms and effective collaboration will be key moving forward.
Social innovation is an approach to social responsibility that requires a unique strategy for every organization, one directly linking their business goals and company values to the common good. The most effective way of implementing this strategy that requires fast-paced, social innovation is by embracing open source principles to enable collaboration across regions and sectors.
For example, [PathCheck][6] Foundation is doing this to quickly and effectively build a platform for shared needs. The PathCheck suite of open source software gives public and private sector organizations solutions for digital contact tracing and exposure notification, with the goal of containing COVID-19 and restarting the economy without sacrificing privacy. Started by Prof. Ramesh Raskar and passionate students at MIT—and now consisting of 1800 volunteers in partnership with many companies, and supported by a newly created nonprofit—PathCheck is a great example of how collaboration on an open source platform is a multiplier (being developed by a growing global, passionate, community of engineers, scientist, health authorities, designers, and contributors, and being used by many governments and organizations than any other service provider).
There is a way to tackle the pandemic and other global issues more effectively through shared platforms and open collaboration. Open source advocates have been doing it for a while, bringing open source to non-profits, governments and corporations, opening up education, connecting open design to global knowledge networks, building open hardware initiatives and structuring open government work. Members of the global open source community have already shown how the post-pandemic world could look—humane, transparent, collaborative, diverse.
Last but not least, the power of the individual aligned with a community—and the power of collaboration for solving issues that are important to all of us—are more powerful than we think. When companies, the public sector, and nonprofits work together, everyone can be part of a _shared_ solution. An open source approach allows every individual to make an impact and contribute to projects using different, complementary skill sets.
Everyone can make a difference every day. And we can use the power of open source to ensure that difference changes the world for good.
--------------------------------------------------------------------------------
via: https://opensource.com/open-organization/20/8/power-open-source-during-pandemic
作者:[Laura Hilliger][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/laurahilliger
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourceprescription.png?itok=gFrc_GTH (Open source prescription.)
[2]: https://www.gov.uk/government/organisations/government-digital-service/about
[3]: https://uil.unesco.org/lifelong-learning/learning-cities
[4]: https://opensource.com/tags/open-organization-greenpeace
[5]: https://opensource.com/open-organization/20/6/covid-alliance
[6]: https://pathcheck.org/

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,140 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( chenmu-kk )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (9 open source tools for building a fault-tolerant system)
[#]: via: (https://opensource.com/article/19/3/tools-fault-tolerant-system)
[#]: author: (Bryant Son (Red Hat, Community Moderator) https://opensource.com/users/brson)
九个用来构建容错系统的开源工具
======
这些开源工具可以最大化延长运行时间并且在最大程度上减少问题。
![magnifying glass on computer screen, finding a bug in the code][1]
我总是对web开发和软件体系结构很感兴趣因为我喜欢看到一个工作系统的更广阔的前景。无论是构建一个移动应用程序还是一个web应用程序都必须连接到internet才能在不同的模块中交换数据这意味着你需要web服务。
如果选择云系统作为应用程序的后端,则可以利用更优秀的计算能力,因为后端服务将会在水平和垂直方向上进行扩展并编排不同的服务。但无论你是否使用云后端,建造一个灵活、稳定、快速又安全的容错系统是必不可少的。
要了解容错系统,让我们以脸书、亚马逊、谷歌和奈飞为例。数以亿计的用户会同时接入这些平台并通过对等网络和用户-服务器网络传输大量数据你可以肯定这其中还存在许多的带有不法目的的恶意用户例如黑客攻击和拒绝服务DoS攻击。即使如此这些平台无需停机也可以全年无休地运转。
尽管机器学习和智能算法是这些系统的基础,但它们实现一致服务而不需要一分钟停机的事实值得称赞。它们昂贵的硬件设备和巨大的数据中心当然十分重要,但是支持服务的精密软件设计也同样重要。而且容错系统是一个构建如此精密系统的法则之一。
### 生产过程中导致错误的两种行为
这是考虑容错系统的另一种方法。当你在本地运行应用程序服务时,每件事似乎都很完美。棒极了!但当你提升服务到生产环境时,一切都会变得一团糟。在这种情况下,容错系统通过解决两个问题来提供帮助:故障停止行为和拜占庭行为。
#### 故障停止行为
故障停止行为是运行中系统突然停止运行或者系统中的某些部分发生了故障时。服务器停机时间和数据库不可访问都属于此种类型。举个例子在下图中由于服务2无法访问因此服务1无法与服务2进行通信。
![Fail-stop behavior due to Service 2 downtime][2]
但是,如果服务之间存在网络问题,也会出现此问题,如下图所示:
![Fail-stop behavior due to network failure][3]
#### 拜占庭行为
拜占庭行为是指系统连续运行,但并不产生预期行为(例如:错误的数据或者无效的数据)。
如果服务2的数据或者值已损坏则可能会发生拜占庭故障即使服务看起来运行得很好比如下面的例子:
![Byzantine failure due to corrupted service][4]
或者,可能存在恶意的中间人在服务之间拦截并注入不需要的数据:
![Byzantine failure due to malicious middleman][5]
故障停止和拜占庭行为都不是理想的情况因此我们需要一些预防或修复它们的手段。这里容错系统就起作用了。以下是可以帮助你解决这些问题的8个开源工具。
### 构建容错系统的工具
尽管构建一个真正实用的容错系统涉及到深入的“分布式计算理论”和复杂的计算机科学原理,但有许多的软件工具(其中许多是开放源代码的软件)通过构建容错系统来减轻不良后果。
#### 断路模式Hystrix 和Resilience4j
[断路模式][6]是一种有助于在服务失败时返回准备好的虚拟回应或者简单回应的一种技术。
![Circuit breaker pattern][7]
奈飞的开源**[Hystrix][8]** 是断路模式中最流行的应用。
我之前工作过的很多家公司都在用这款出色的工具。令人意外的是奈飞宣布将不再更新Hystrix是的我知道。相反奈飞建议使用另一种支持Java8和函数式编程的[**Resilence4j**][9]之类的替代解决方案,或者类似于[Adaptive Concurrency Limit][10]的适应性解决方案。
#### 负载均衡Nginx 和HaProxy
负载均衡是分布式系统中最基本的概念之一它必须具备生产质量的环境。要理解负载均衡器首先我们需要明白冗余的概念。每个生产质量的web服务都有多个服务器在服务器宕机时提供冗余来接管和维持服务。
![Load balancer][11]
想想现代飞机:它们的双引擎提供冗余,使它们即使在一个引擎着火的情况下也能安全的着陆。(这也有助于大多数商用飞机拥有最先进的自动化系统)。但是,拥有多引擎(或者多服务器)也意味着必须存在一些调度机制在故障时有效地对系统进行路由。
负载均衡器是一种通过平衡多个服务节点来优化重流量事务的设备或者软件。举个例子,当数以千计的请求涌入时,负载均衡器可以作为中间层在不同的服务期间路由和平均分配流量。如果服务器宕机,负载均衡器会将请求转发给其他运行良好的服务器。
有许多可用的负载均衡器但其中最出名的两个就是Nginx 和HaProxy。
[**Nginx**][12]不仅仅是一个负载均衡器。它是HTTP和反向代理服务器、邮件代理服务器和通用TCP/UDP代理服务器。Groupon、Capital One、 Adobe和NASA等公司都在使用它。
[**HaProxy**][13] 也很受欢迎因为它是一个免费快且可靠的解决方案它为基于TCP和HTTP的应用程序提供高可用性、负载平衡和代理。许多大型网络公司包括Github、Reddit、Twitter和Stack Overflow都使用HaProxy。是的Red Hat Enterprise Linux同样支持HaProxy设置。
#### 参与者模型Akka
[参与者模型][14] 是一种并发设计模式当作为基本计算单位的_actor_接收到消息时它会分派责任。一个actor可以创建更多的actor并将消息委派给他们。
[**Akka**][15] 是用于actor模式实现的最著名工具之一。框架同时支持基于JVM的Java和Scala。
#### 使用消息队列的异步、非阻塞I/O:Kafka和RabbitMQ
多线程开发在过去很流行但是这种做法一直不被鼓励取而代之的是异步的、非阻塞的I/O模式。对于Java这一点在[EnterpriseJavaBeanEJB规范][16]中明确说明:
> “企业bean一定不能使用线程同步原语来同步多个实例的执行。”
>
> “企业bean不得试图去管理线程。企业bean不得试图启动、停止、挂起或恢复线程或者去更改线程的优先级或者名称。企业bean不得试图管理线程组。”
如今有其他做法像流API和参与者模型。但像[**Kafka**][17] 和[**RabbitMQ**][18]之类的消息队列为异步和非阻塞IO功能提供了开箱即用的支持同时它们也是功能强大的开源工具通过处理并发进程可以替代线程。
#### 其他的选择Eureka 和Chaos Monkey
用于容错系统其他有用的工具包括奈飞的**[Eureka][19]** 之类的监控工具,以及像 **[Chaos Monkey][20]** 这样的压力测试工具。它们旨在通过在较低环境中的测试像集成INT质量保障QA和用户接受测试UAT来早早发现潜在问题以防止在转移到生产环境之前出现潜在问题。
* * *
你在使用什么开源工具来构建一个容错系统呢?请在评论中分享您的收藏夹。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/3/tools-fault-tolerant-system
作者:[Bryant Son (Red Hat, Community Moderator)][a]
选题:[lujun9972][b]
译者:[chenmu-kk](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/brson
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga (magnifying glass on computer screen, finding a bug in the code)
[2]: https://opensource.com/sites/default/files/uploads/1_errordowntimeservice.jpg (Fail-stop behavior due to Service 2 downtime)
[3]: https://opensource.com/sites/default/files/uploads/2_errordowntimenetwork.jpg (Fail-stop behavior due to network failure)
[4]: https://opensource.com/sites/default/files/uploads/3_byzantinefailuremalicious.jpg (Byzantine failure due to corrupted service)
[5]: https://opensource.com/sites/default/files/uploads/4_byzantinefailuremiddleman.jpg (Byzantine failure due to malicious middleman)
[6]: https://martinfowler.com/bliki/CircuitBreaker.html
[7]: https://opensource.com/sites/default/files/uploads/5_circuitbreakerpattern.jpg (Circuit breaker pattern)
[8]: https://github.com/Netflix/Hystrix/wiki
[9]: https://github.com/resilience4j/resilience4j
[10]: https://medium.com/@NetflixTechBlog/performance-under-load-3e6fa9a60581
[11]: https://opensource.com/sites/default/files/uploads/7_loadbalancer.jpg (Load balancer)
[12]: https://www.nginx.com
[13]: https://www.haproxy.org
[14]: https://en.wikipedia.org/wiki/Actor_model
[15]: https://akka.io
[16]: https://jcp.org/aboutJava/communityprocess/final/jsr220/index.html
[17]: https://kafka.apache.org
[18]: https://www.rabbitmq.com
[19]: https://github.com/Netflix/eureka
[20]: https://github.com/Netflix/chaosmonkey

View File

@ -0,0 +1,55 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (AI system analyzes code similarities, makes progress toward automated coding)
[#]: via: (https://www.networkworld.com/article/3570389/ai-system-analyzes-code-similarities-makes-progress-toward-automated-coding.html)
[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/)
AI 系统分析代码相似性,向自动化编码迈进
======
来自 Intel、MIT 和佐治亚理工学院的研究人员正在研究一个 AI 引擎,它可以分析代码的相似性,以确定代码的实际作用,为自动化软件编写奠定基础。
随着人工智能 AI 的快速发展,我们是否会进入计算机智能到足以编写自己的代码并和人类一起完成工作?新的研究表明,我们可能正在接近这个里程碑。
来自 MIT 和佐治亚理工学院的研究人员与 Intel 合作开发了一个人工智能引擎被称为机器推断代码相似性MISIM它旨在分析软件代码并确定它与其他代码的相似性。最有趣的是该系统有学习代码的潜力然后利用这种智能来改变软件的编写方式。最终人们可以解释希望程序做什么然后机器编程 MP 系统可以拿出一个已经编写完的应用。
Intel 首席科学家兼机器编程研究总监/创始人 Justin Gottschlich 在该公司的[新闻稿][2]中说“当完全实现时MP 能让每个人都能以任何最适合自己的方式,无论是代码、自然语言还是其他东西,来表达自己的意图来创建软件。这是一个大胆的目标,虽然还有很多工作要做,但 MISIM 是朝着这个目标迈出的坚实一步。"
### 它是如何工作的
Intel 解释说,神经网络”根据它们被设计执行的作业“给代码片段打出相似度分数。例如,两个代码样本可能看起来完全不同,但由于它们执行相同的功能,因此被评为相同。然后,该算法可以确定哪个代码片段更有效率。
例如,代码相似性系统的原始版本被用于抄袭检测。然而,有了 MISIM该算法会查看代码块并试图根据上下文确定这些代码段是否具有相似的特征或者是否有相似的目标。然后它可以提供例如性能方面的改进或者常规效率。
MISIM 的关键是创造者的意图,它标志着向基于意图的编程的进步,它可以使软件的设计基于非程序员创造者想要实现的目标。通过基于意图的编程,算法会借助于一个开源代码池,而不是依靠传统的、手工的方法,编译一系列类似于步骤的编程指令,逐行告诉计算机如何做某件事。
Intel 解释说”MISIM 与现有代码相似性系统的核心区别在于其新颖的上下文感知语义结构 CASS其目的是将代码的实际作用提炼出来。与其他现有的方法不同CASS 可以根据特定的上下文进行配置使其能够捕捉到更高层次的代码描述信息。CASS 可以更具体地洞察代码的作用,而不是它是如何做的。“
这是在没有编译器(编程中的一个阶段,将人类可读代码转换为计算机程序)的情况下完成的。方便的是,部分片段可以被执行,只是为了看看那段代码中会发生什么。另外,该系统摆脱了软件开发中一些比较繁琐的部分,比如逐行查找错误。更多细节可以在该小组的论文([PDF][3] 中找到。
Intel 表示,该团队的 MISIM 系统比之前的代码相似性系统识别相似代码的准确率高 40 倍。
一个 RedditorHeres_your_sign [对 MISIM 报道][4]的评论中有趣地指出,幸好计算机不写需求。这位 Redditor 认为,那是自找麻烦。
加入 [Facebook][5] 和 [LinkedIn][6] 上的 Network World 社区,对热门的话题进行评论。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3570389/ai-system-analyzes-code-similarities-makes-progress-toward-automated-coding.html
作者:[Patrick Nelson][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Patrick-Nelson/
[b]: https://github.com/lujun9972
[2]: https://newsroom.intel.com/news/intel-mit-georgia-tech-machine-programming-code-similarity-system/#gs.d8qd40
[3]: https://arxiv.org/pdf/2006.05265.pdf
[4]: https://www.reddit.com/r/technology/comments/i2dxed/this_ai_could_bring_us_computers_that_can_write/
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world