微服务的10个挑战和解决方案 - 提示和技巧

mobdev 7月前 ⋅ 326 阅读

概要:微服务的创纪录增长正在破坏运营环境,本篇文章介绍了,互联网公司和开源社区旨在解决的微服务架构面临的十大挑战。 微服务的10个挑战和解决方案 - 提示和技巧 10 Challenges and Solutions for Microservi...

I am a cloud API developer and architect and currently working on Google's GCP based microservices for a large retail client of USA.

我是一名云API开发人员和架构师,目前正致力于为美国的大型零售客户提供基于Google的GCP微服务。

Transitioning/implementing to microservices creates significant challenges for organizations. I have identified these challenges and solution based on my exposure to microservices in production. 

渡/实施微服务给组织带来了重大挑战。基于我对生产环境中的微服务的深入理解,我已经确定了这些挑战和解决方案。 

I am writing this in June 2018. At this time, microservices architecture has not matured enough to completely address all the existing challenges, however, open source communities and IT product companies are trying to address all these open issues. All new research on this topics is based on finding solutions to the new challenges.

我在2018年6月写这篇文章。目前,微服务架构尚未成熟到足以完全解决所有现有挑战,但是,开源社区和IT产品公司正试图解决所有这些未解决的问题。关于这一主题的所有新研究都是基于寻找新挑战的解决方案。

These are the ten major challenges of microservices architecture and proposed solutions:

这些是微服务架构和提出的解决方案的十大挑战:

1. Data Synchronization — We have event sourcing architecture to address this issue using the async messaging platform. The saga design pattern can address this challenge.

数据同步  - 我们使用事件源代码架构来使用异步消息传递平台解决此问题。saga设计模式(无中心协调者模式)可以应对这一挑战

2. Security — An API Gateway can solve these challenges. Kong is very popular and is open-source, and is being used by many companies in production. Custom solutions can also be developed for API security using JWT token, Spring Security, and Netflix Zuul/ Zuul2. There are enterprise solutions available, too, like Apigee and Okta (2-step authentication). Openshift is used for public cloud security for its top features, like Red Hat Linux Kernel-based security and namespace-based app-to-app security.

安全性  - API网关可以解决这些挑战。Kong非常受欢迎,并且是开源的,并且正在被许多公司用于生产。还可以使用JWT令牌,Spring Security和Netflix Zuul / Zuul2为API安全性开发自定义解决方案。还有企业解决方案,如Apigee和Okta(两步认证)。Openshift用于公共云安全的顶级功能,如基于Red Hat Linux Kernel的安全性和基于命名空间的app-to-app安全性。

3. Versioning — This will be taken care of by API registry and discovery APIs using the dynamic Swagger API, which can be updated dynamically and shared with consumers on the server.

版本控制  - 这将由API注册表和发现API使用动态Swagger API处理,动态Swagger API可以动态更新并与服务器上的使用者共享。

4. Discovery — This will be addressed by API discovery tools like Kubernetes and OpenShift. It can also be done using Netflix Eureka at the code level. However, doing it in with the orchestration layer will be better and can be managed by these tools rather doing and maintaining it through code and configuration.

发现  - 这将由Kubernetes和OpenShift等API发现工具解决。它也可以在代码级使用Netflix Eureka完成。但是,使用业务流程层执行此操作会更好,并且可以通过这些工具进行管理,而不是通过代码和配置进行维护。

5. Data Staleness — The database should be always updated to give recent data. The API will fetch data from the recent and updated database. A timestamp entry can also be added with each record in the database to check and verify the recent data. Caching can be used and customized with an acceptable eviction policy based on business requirements.

数据过期 -  应始终更新数据库以提供最新数据。API将从最近更新的数据库中获取数据。还可以为数据库中的每条记录添加时间戳条目,以检查和验证最近的数据。可以根据业务需求使用可定义的驱逐策略来使用和自定义缓存。

6. Debugging and Logging — There are multiple solutions for this. Externalized logging can be used by pushing log messages to an async messaging platform like Kafka, Google PubSub, etc. A correlation ID can be provided by the client in the header to REST APIs to track the relevant logs across all the pods/Docker containers. Also, local debugging can be done individually on each microservice using the IDE or checking the logs.

调试和记录  - 有多种解决方案。可以通过将日志消息推送到异步消息平台(如Kafka,Google PubSub等)来使用外化日志记录。客户端可以在标头中为REST API提供关联ID,以跟踪所有pod / Docker容器中的相关日志。此外,可以使用IDE或检查日志在每个微服务上单独完成本地调试。

7. Testing — This issue can be addressed with unit testing by mocking REST APIs or integrated/dependent APIs which are not available for testing using WireMock, BDD, Cucumber, integration testing, performance testing using JMeter, and any good profiling tool like Jprofiler, DynaTrace, YourToolKit, VisualVM, etc.

测试 -  可以通过模拟REST API或集成/依赖API来解决此问题,这些API不可用于使用WireMock,BDD,Cucumber,集成测试,使用JMeter进行性能测试以及任何良好的分析工具(如Jprofiler)进行测试, DynaTrace,YourToolKit,VisualVM等

8. Monitoring — Monitoring can be done using open-source tools like Prometheus in combination with Grafana by creating gauge and matrices, Kubernetes/OpensShift, Influx DB, Apigee, combined with Grafana, and Graphite.

监控  - 监控可以使用开源工具,如Prometheus与Grafana结合使用,创建仪表和矩阵,Kubernetes / OpensShift,Influx DB,Apigee,结合Grafana和Graphite。

9. DevOps Support — Microservices deployment and support-related challenges can be addressed using state-of-the-art DevOps tools like GCP, Kubernetes, and OpenShift with Jenkins.

DevOps支持 -  使用最先进的DevOps工具(如GCP,Kubernetes和OpenShift与Jenkins)可以解决微服务部署和支持相关的挑战。

10. Fault Tolerance — Netflix Hystrix can be used to break the circuit if there is no response from the API for the given SLA/ETA.

容错  - 如果给定SLA / ETA的API没有响应,Netflix Hystrix可用于断开链路。


全部评论: 0

    我有话说: