애플리케이션 구성요소와 시스템 구성요소 간의 종속 항목을 파악하여 확장 가능한 시스템을 설계합니다.
모듈식 설계를 사용하면 모놀리식 아키텍처가 처음 배포되었는지 마이크로서비스 아키텍처가 처음 배포되었는지에 관계없이 유연성과 복원력을 확보할 수 있습니다. 명확한 인터페이스가 있는 잘 정의된 독립 모듈로 시스템을 분해하면 특정 요구사항을 충족하도록 개별 구성요소를 확장할 수 있습니다.
타겟팅된 확장/축소는 다음과 같은 방식으로 리소스 사용률을 최적화하고 비용을 절감하는 데 도움이 됩니다.
각 구성요소에 필요한 리소스만 프로비저닝하고, 요구사항이 적은 구성요소에는 더 적은 리소스를 할당합니다.
트래픽이 많은 기간에 사용자 환경을 유지하기 위해 리소스를 추가합니다.
성능을 저하시키지 않고 사용률이 낮은 리소스를 삭제합니다.
모듈화는 유지보수성도 향상합니다. 작고 자체 포함된 단위는 이해하고 디버그하고 업데이트하기가 더 쉬우므로 개발 주기가 빨라지고 위험이 줄어들 수 있습니다.
모듈성은 상당한 이점을 제공하지만 잠재적인 성능 트레이드오프를 평가해야 합니다. 모듈 간 통신이 증가하면 지연 시간과 오버헤드가 발생할 수 있습니다. 모듈성과 성능 간의 균형을 유지하세요. 고도로 모듈화된 설계가 보편적으로 적합하지 않을 수 있습니다. 성능이 중요한 경우 더 긴밀하게 결합된 접근 방식이 적합할 수 있습니다.
시스템 설계는 모듈식 설계를 지속적으로 검토하고 개선하는 반복적인 프로세스입니다.
권장사항
모듈식 설계를 장려하려면 다음 섹션의 권장사항을 고려하세요.
느슨한 결합을 위한 설계
느슨하게 결합된 아키텍처를 설계합니다.
종속 항목이 최소화된 독립적인 구성요소를 사용하면 확장 가능하고 복원력이 우수한 애플리케이션을 빌드할 수 있습니다.
서비스의 경계를 계획할 때는 가용성 및 확장성 요구사항을 고려해야 합니다. 예를 들어 한 구성요소의 요구사항이 다른 구성요소와 다른 경우 해당 구성요소를 독립형 서비스로 설계할 수 있습니다. 덜 중요한 하위 프로세스나 기본 서비스의 응답 시간에 영향을 미치지 않는 서비스에 대한 정상적인 실패 계획을 구현합니다.
동시 실행 및 동시 로드를 위한 설계
사용자가 시스템과 상호작용하는 동안 여러 사용자 요청을 처리하거나 백그라운드 작업을 실행하는 등 여러 작업을 동시에 지원하도록 애플리케이션을 설계하세요. 여러 서비스 인스턴스에서 동시에 처리할 수 있는 작은 단위로 큰 작업을 나눕니다. 태스크 동시 실행을 사용하면 자동 확장과 같은 기능을 사용하여 다음과 같은 제품에서 리소스 할당을 늘릴 수 있습니다.
가능한 경우 각 구성요소는 특정 작업에 필요한 리소스(예: 메모리, 저장소, 처리 능력)만 사용해야 합니다. 리소스 과할당은 불필요한 비용을 초래할 수 있고 리소스 부족 할당은 성능을 저하시킬 수 있습니다.
잘 정의된 인터페이스 사용
모듈식 구성요소가 명확하고 표준화된 인터페이스 (예: API 및 메시지 대기열)를 통해 효과적으로 통신하여 변환 레이어 또는 불필요한 트래픽으로 인한 오버헤드를 줄여야 합니다.
스테이트리스(Stateless) 모델 사용
스테이트리스(Stateless) 모델은 이전 요청과 관계없이 서비스에서 각 요청 또는 상호작용을 처리할 수 있도록 지원합니다. 이 모델은 진행 중인 요청 또는 프로세스에 필요한 데이터가 손실되는 일 없이 서비스를 확장 또는 축소하거나 재시작할 수 있으므로, 확장성과 복구 성능에 도움을 줍니다.
상호 보완적인 기술 선택
모듈식 설계를 보완하는 기술을 선택합니다. 모듈성 지원을 위해 프로그래밍 언어, 프레임워크, 데이터베이스를 평가합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-06(UTC)"],[[["\u003cp\u003eModular design enhances system flexibility and resilience by enabling the independent scaling, updating, and potential separation of components.\u003c/p\u003e\n"],["\u003cp\u003eBreaking down systems into independent modules with clear interfaces allows for targeted scaling, optimizing resource utilization and reducing costs by only provisioning necessary resources.\u003c/p\u003e\n"],["\u003cp\u003eModularity improves maintainability, making smaller, self-contained units easier to understand, debug, and update, which in turn leads to quicker development cycles and risk reduction.\u003c/p\u003e\n"],["\u003cp\u003eWhen designing for modularity, consider loose coupling, concurrency, and parallelism to build scalable and resilient applications, alongside balancing resource allocation and using well-defined interfaces.\u003c/p\u003e\n"],["\u003cp\u003eEmploying stateless models and selecting complementary technologies that support modularity can further improve scalability and recoverability, allowing the system to adapt without losing data.\u003c/p\u003e\n"]]],[],null,["# Promote modular design\n\nThis principle in the performance optimization pillar of the\n[Google Cloud Well-Architected Framework](/architecture/framework)\nprovides recommendations to help you promote a modular design.\nModular components and clear interfaces can enable flexible scaling,\nindependent updates, and future component separation.\n\nPrinciple overview\n------------------\n\nUnderstand the dependencies between the application components and the system\ncomponents to design a scalable system.\n\nModular design enables flexibility and resilience, regardless of whether a\nmonolithic or microservices architecture was initially deployed. By decomposing\nthe system into well-defined, independent modules with clear interfaces, you can\nscale individual components to meet specific demands.\n\nTargeted scaling can help optimize resource utilization and reduce costs in the\nfollowing ways:\n\n- Provisions only the necessary resources to each component, and allocates fewer resources to less-demanding components.\n- Adds more resources during high-traffic periods to maintain the user experience.\n- Removes under-utilized resources without compromising performance.\n\nModularity also enhances maintainability. Smaller, self-contained units are\neasier to understand, debug, and update, which can lead to faster development\ncycles and reduced risk.\n\nWhile modularity offers significant advantages, you must evaluate the potential\nperformance trade-offs. The increased communication between modules can\nintroduce latency and overhead. Strive for a balance between modularity and\nperformance. A highly modular design might not be universally suitable. When\nperformance is critical, a more tightly coupled approach might be appropriate.\nSystem design is an\n[iterative process](/architecture/framework/performance-optimization),\nin which you continuously review and refine your modular design.\n\nRecommendations\n---------------\n\nTo promote modular designs, consider the recommendations in the following\nsections.\n\n### Design for loose coupling\n\nDesign a\n[loosely coupled architecture](/architecture/microservices-architecture-refactoring-monoliths).\nIndependent components with minimal dependencies can help you build\n[scalable and resilient applications](/architecture/scalable-and-resilient-apps).\nAs you plan the boundaries for your services, you must consider the availability\nand scalability requirements. For example, if one component has requirements that\nare different from your other components, you can design the component as a standalone\nservice. Implement a plan for graceful failures for less-important subprocesses\nor services that don't impact the response time of the primary services.\n\n### Design for concurrency and parallelism\n\nDesign your application to support multiple tasks concurrently, like processing\nmultiple user requests or running background jobs while users interact with your\nsystem. Break large tasks into smaller chunks that can be processed at the same\ntime by multiple service instances. Task concurrency lets you use features like\nautoscaling to increase the resource allocation in products like the following:\n\n- [Compute Engine](/compute/docs/autoscaler)\n- [GKE](/spanner/docs/autoscaling-overview)\n- [BigQuery](/bigquery/docs/slots-autoscaling-intro)\n- [Spanner](/spanner/docs/autoscaling-overview)\n\n### Balance modularity for flexible resource allocation\n\nWhere possible, ensure that each component uses only the necessary resources\n(like memory, storage, and processing power) for specific operations. Resource\nover-allocation can result in unnecessary costs, while resource under-allocation can\ncompromise performance.\n\n### Use well-defined interfaces\n\nEnsure modular components communicate effectively through clear, standardized\ninterfaces (like APIs and message queues) to reduce overhead from translation\nlayers or from extraneous traffic.\n\n### Use stateless models\n\nA stateless model can help ensure that you can handle each request or interaction with\nthe service independently from previous requests. This model facilitates\nscalability and recoverability, because you can grow, shrink, or restart the\nservice without losing the data necessary for in-progress requests or\nprocesses.\n\n### Choose complementary technologies\n\nChoose technologies that complement the modular design. Evaluate programming\nlanguages, frameworks, and databases for their modularity support.\n\nFor more information, see the following resources:\n\n- [Re-architecting to cloud native](https://cloud.google.com/resources/rearchitecting-to-cloud-native)\n- [Introduction to microservices](/architecture/microservices-architecture-introduction)"]]