简体   繁体   English

什么是微服务,与 MVC 有什么联系

[英]What is Microservices and is there a connection with MVC

I'm familiar with spring boot framework and I developed an Application which helps to handle online Assignments.I used few service classes to handle different tasks of the application and its structure can be seen here.我熟悉 spring boot 框架,我开发了一个帮助处理在线作业的应用程序。我使用了很少的服务类来处理应用程序的不同任务,它的结构可以在这里看到。

我的项目的文件结构

And I have seen several complex applications built as independent packages based on the task it do in the application.我已经看到几个复杂的应用程序根据它在应用程序中执行的任务构建为独立的包。

(1) My First question is can my Application be called as a MicroServices Application?? (1) 我的第一个问题是我的应用程序可以称为微服务应用程序吗?? Because I have used independent services for the application development.因为我在应用程序开发中使用了独立的服务。

(2) And my second question is Can a application developed in MicroServices Architecture has MVC Architecture at the same time.But I have seen in several tutorials they are 2 different architectures.But a Moicroservices Application also has Models ,Views and Controllers at the same time. (2) 我的第二个问题是在微服务架构中开发的应用程序是否可以同时具有 MVC 架构。但是我在几个教程中看到它们是两种不同的架构。但是一个 Moicroservices 应用程序也同时具有模型、视图和控制器时间。

So can those 2 be used at the same time??那么这两个可以同时使用吗??

Thank you!!谢谢!!

Microservices according to Chris Richardson ( recognized thought leader in microservices) is Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are根据 Chris Richardson(微服务领域公认的思想领袖)的说法,微服务是微服务 - 也称为微服务架构 - 是一种架构风格,它将应用程序构建为服务的集合

Highly maintainable and testable Loosely coupled Independently deployable Organized around business capabilities Owned by a small team The microservice architecture enables the rapid, frequent and reliable delivery of large, complex applications.高度可维护和可测试 松散耦合 可独立部署 围绕业务能力组织 由一个小团队拥有 微服务架构使大型复杂应用程序能够快速、频繁、可靠地交付。 It also enables an organization to evolve its technology stack.它还使组织能够发展其技术堆栈。

It is way of delivery and based on 12 factors https://12factor.net/ .这是交付方式,基于 12 个因素https://12factor.net/ We use domain driven design as one of the way.我们使用领域驱动设计作为其中一种方式。

MVC is way of designing as service where we have model view and controller. MVC 是设计为服务的方式,我们有模型视图和控制器。

In Microservices architecture we can use MVC in one way where each component will be distributed .在微服务架构中,我们可以以一种方式使用 MVC,其中每个组件都将被分布。

Please go through the Microservice Patterns.请阅读微服务模式。 It is very good book to understand the Microservices architecture很好的了解微服务架构的书

1.Answer to your question yes your application can be Microservices if it followed the 12 factors as mentioned in the website . 1.回答您的问题,是的,如果您的应用程序遵循网站中提到的 12 个因素,则它可以是微服务。

  1. Yes Microservices can be on the pattern of mvc but they will be distributed and like we have Microservices for backend in similar fashion we have micro frontend for UI .是的,微服务可以采用 mvc 模式,但它们将是分布式的,就像我们有后端微服务一样,我们有 UI 微前端。

You should do some deeper research yourself about the concept and theory of microservices.您应该自己对微服务的概念和理论进行更深入的研究。 Studying other applications without the basic knowledge can be misleading.在没有基础知识的情况下研究其他应用程序可能会产生误导。

(1) Just because you are using multiple classes called services does not mean, you are building microservices application. (1) 仅仅因为您使用多个称为服务的类并不意味着您正在构建微服务应用程序。 Microservice application examples can be - student management rest api, question and answer management rest api, UI for administration, UI for public usage etc. All of them can be separate spring boot apps, or any other technology capable of handling the requirements (node.js, python, php, Asp.net ...) You should be able to deploy, test and use them as separate standalone apps.微服务应用示例可以是 - 学生管理休息 api、问答管理休息 api、用于管理的 UI、用于公共使用的 UI 等。它们都可以是单独的 Spring Boot 应用程序,或任何其他能够处理需求的技术(node.js)。 js、python、php、Asp.net ...)您应该能够将它们作为单独的独立应用程序进行部署、测试和使用。

(2)I think a microservice app does not need views, it can be a rest/soap app, log aggregation app, health check app, messaging service app etc. But different types can use different architecture, one of which can be MVC. (2)我认为微服务应用程序不需要视图,它可以是rest/soap应用程序、日志聚合应用程序、健康检查应用程序、消息服务应用程序等。但不同类型可以使用不同的架构,其中之一可以是MVC。

By definition of M. Fowler microservices are根据M. Fowler 的定义,微服务是

..an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. ..一种将单个应用程序开发为一组小型服务的方法,每个服务都在自己的进程中运行并与轻量级机制(通常是 HTTP 资源 API)进行通信。

As you see the definition is ambiguous.如您所见,定义不明确。 I think you are building a monolith application with a good separation of responsibilities into classes called XyServices - a possible candidates to migrate to microservices.我认为您正在构建一个单体应用程序,将职责很好地分离到称为XyServices类中 - 一个可能迁移到微服务的候选者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker中的两个微服务拒绝连接 - Connection refused with two microservices in Docker Spring 微服务 Docker 问题(连接被拒绝和数据库连接) - Spring Microservices Docker Issues (Connection Refused and Database Connection) Spring Boot-与微服务有什么关系? - Spring Boot - What's it got to do with microservices? 谈到微服务,什么是资源服务器? - What is a Resource Server when it comes to Microservices? 微服务和去中心化应用之间的区别是什么 - What is difference between Microservices and Decentralized applications 微服务-连接到单个旧数据库时的连接池 - Microservices - Connection Pooling when connecting to a single legacy database 如何限制 spring 启动应用程序运行微服务创建的数据库连接 - how to limit the database connection created by spring boot application running microservices 事件驱动和领域驱动设计微服务有什么区别? - what is the difference between event driven and domain driven design Microservices? 在微服务架构(春季启动)中分离实体的最佳方法是什么? - What is the best approach to seperate entities in microservices architecture (spring boot)? spring部署在Kube.netes中的启动微服务的日志集中处理的正确方法是什么? - What are the proper ways to centralize the logs of spring boot microservices deployed in Kubernetes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM