@manhng

Welcome to my blog!

Microservices

May 4, 2019 11:17

Microservices (edit)

Google Drive

https://drive.google.com/drive/u/0/folders/1uDAm6JhOebJKG7EBsyfdZUumIxZccKSp

Việc chuyển sang microservices sẽ giúp việc phát triển ứng dụng nhanh hơn và dễ quản lý hơn, yêu cầu ít nhân lực hơn để triển khai nhiều tính năng mới hơn. Các thay đổi có thể được thực hiện và triển khai nhanh hơn và dễ dàng hơn. Ứng dụng được thiết kế như một tập các microservices dễ dàng chạy trên nhiều máy chủ với cân bằng tải (load balancing), giúp dễ dàng xử lý các yêu cầu tăng đột biến và nhu cầu tăng theo thời gian, đồng thời giảm thời gian chết (downtime) do các vấn đề về phần cứng hoặc phần mềm.

Microservices là một phần quan trọng trong các tiến bộ đang thay đổi cách chúng ta làm việc ngày nay. Các kỹ thuật Agile software development, chuyển các ứng dụng lên cloud, văn hóa DevOps, tích hợp liên tục và triển khai liên tục (CI / CD), và việc sử dụng containers đều được sử dụng cùng với microservices để tạo nên cuộc cách mạng hóa trong phát triển và phân phối ứng dụng

Nội dung chính trong phần lý thuyết bao gồm:

  1. Giới thiệu về Microservices – giới thiệu rõ ràng và đơn giản về microservices, từ khái niệm đến thực tế cách các microservices được triển khai và duy trì
  2. API Gateway – API Gateway là điểm đầu vào duy nhất cho toàn bộ ứng dụng dựa trên microservices
  3. Inter-process Communication – Một khi bạn tách một ứng dụng nguyên khối thành từng phần riêng biệt – các microservices – khi đó các service cần nói chuyện với nhau. Và có nhiều lựa chọn giao tiếp giữa các process, điển hình như REST.
  4. Service Discovery – Khi các service đang chạy trong một môi trường động, việc tìm kiếm chúng khi cần không phải là vấn đề đơn giản. Cùng xem cách giải quyết vấn đề đó trong bài này nhé.
  5. Event-Driven Data Management – Thay vì chia sẻ một database toàn cục (hoặc hai) trên một ứng dụng nguyên khối, mỗi microservice sẽ tự biểu diễn và lưu trữ dữ liệu riêng của nó. Điều này mang đến sự linh hoạt tuyệt vời, nhưng cũng có thể gây ra sự phức tạp.
  6. Chiến lược triển khai (Deployment Strategy) cho Microservices – Trong thế giới DevOps, cách bạn làm mọi thứ cũng quan trọng như những gì bạn đặt ra để làm ngay từ đầu. Chris mô tả những patterns chính cho việc triển khai microservices để có thể đưa ra lựa chọn sáng suốt cho bạn
  7. Tái cấu trúc Monolith sang Microservices – Trong một thế giới hoàn hảo, chúng ta sẽ luôn có được thời gian và tiền bạc để thay đổi, cập nhật phần mềm với các công nghệ, công cụ và phương pháp mới nhất và tốt nhất. Nhưng trong bài viết này, Chris sẽ trình bày một chiến lược để làm điều này một cách hợp lý cho việc chuyển đổi từ Monolith sang Microservices. Một … mảnh … nhỏ … tại … một … thời điểm.

A Kubernetes-based microservices application on service mesh

https://github.com/vietnam-devs/coolstore-microservices

https://vietnam-devs.github.io/coolstore-microservices/

Microservice Design Patterns

 

Microservices Patterns IO

https://www.oreilly.com/library/view/monolith-to-microservices/9781492047834/

https://www.oreilly.com/programming/free/files/microservices-antipatterns-and-pitfalls.pdf (eBook)

https://www.kislayverma.com/amp/code-review-checklist-for-distributed-systems (Check List)

https://www.nginx.com/resources/library/monolith-to-microservices/

https://microservices.io/patterns/microservices.html

https://microservices.io/refactoring/

https://github.com/microservices-patterns/ftgo-monolith

You’ll learn several tried and tested patterns and techniques that you can use as you migrate your existing architecture.

  • Ideal for organizations looking to transition to microservices, rather than rebuild
  • Helps companies determine whether to migrate, when to migrate, and where to begin
  • Addresses communication, integration, and the migration of legacy systems
  • Discusses multiple migration patterns and where they apply
  • Provides database migration examples, along with synchronization strategies
  • Explores application decomposition, including several architectural refactoring patterns
  • Delves into details of database decomposition, including the impact of breaking referential and transactional integrity, new failure modes, and more

Dev Mentors

https://github.com/devmentors

https://www.youtube.com/watch?v=6YYB8vv3pZg&list=PLqqD43D6Mqz38LoZEuo_hJAp2NxXskcut&index=1

Building microservices on Azure - https://docs.microsoft.com/en-us/azure/architecture/microservices/

Microservices architecture on Azure Kubernetes Service (AKS) - https://docs.microsoft.com/en-us/azure/architecture/reference-architectures/microservices/aks

Microservices with AKS - https://docs.microsoft.com/en-us/azure/architecture/solution-ideas/articles/microservices-with-aks

Blog Series - Building Microservices

https://callistaenterprise.se/blogg/teknik/2015/05/20/blog-series-building-microservices/

https://edwardthienhoang.wordpress.com/microservices-tu-thiet-ke-den-trien-khai-phan-mo-dau/

Pollyhttps://github.com/App-vNext/Polly

Microservices implementation — Netflix stack

https://medium.com/@tharanganilupul/microservices-implementation-netflix-stack-ba4f4a57a79f

Microservices: The SAGA Pattern for distributed transactions

https://medium.com/@ijayakantha/microservices-the-saga-pattern-for-distributed-transactions-c489d0ac0247

What is dapr?

https://dev.to/arschles/what-is-dapr-526a

Distributed .NET Core (DShop) - Episode 1 [Intro, HTTP requests flow, Infrastructure with Docker]

https://www.youtube.com/watch?v=s4fd3PRlOcw

Distributed .NET Core (DShop) - Episode 2 [CQRS - Write side, Discounts service, MongoDB repository]

https://www.youtube.com/watch?v=yqh0dN4oDTs

Distributed .NET Core (DShop) - Episode 3 [Subscribing RabbitMQ messages, API gateway]

https://www.youtube.com/watch?v=L9UUUPedidg

Distributed .NET Core (DShop) - Episode 4 [Asynchronous microservices integration via events]

https://www.youtube.com/watch?v=KiIetmswEos

Distributed .NET Core (DShop) - Episode 5 [CQRS - Read side, Internal HTTP communication]

https://www.youtube.com/watch?v=o0fMHARUwq0

Distributed .NET Core (DShop) - Episode 6 [Service discovery & Load balancing with Consul + Fabio]

https://www.youtube.com/watch?v=UWfn8Iml2Kc

Distributed .NET Core (DShop) - Episode 7 [Handling asynchronous requests, SignalR, Polly]

https://www.youtube.com/watch?v=rKmL2Onh4hg

Distributed .NET Core (DShop) - Episode 8 [Distributed transactions, 2PC, Event Choreography, Saga]

https://www.youtube.com/watch?v=KI223ULIFoA

Distributed .NET Core (DShop) - Episode 9 [Vault secrets, Seq logging, Jaeger distributed tracing]

https://www.youtube.com/watch?v=8bDHf7yiNKM

Distributed .NET Core (DShop) - Episode 10 [Metrics with AppMetrics, InfluxDB, Prometheus, Grafana]

https://www.youtube.com/watch?v=2OiE-h9sNM4

Distributed .NET Core (DShop) - Episode 11 [Travis CI pipelines, custom MyGet feeds]

https://www.youtube.com/watch?v=sS9yB7m_OsQ

Distributed .NET Core (DShop) - Episode 12 [Docker basics, Docker Hub, docker-compose]

https://www.youtube.com/watch?v=drD0vgKecAc

Distributed .NET Core (DShop) - Episode 13 [Integration tests with xUnit, Web API, Mongo, RabbitMQ]

https://www.youtube.com/watch?v=fDe_Neayo9I

Distributed .NET Core (DShop) - Episode 14 [Consumer-driven contract testing with Pact]

https://www.youtube.com/watch?v=qRCY5BTYQk0

Distributed .NET Core (DShop) - Episode 15 [Orchestration with Portainer, Kubernetes and Rancher]

https://www.youtube.com/watch?v=YxvB6-6FSZE

Building a CI/CD pipeline for a containerized Asp.Net Core 3.0 Web API

https://www.youtube.com/watch?v=nsG3xbIoeJo

ElasticSearch on Windows 10 and .NET Core

https://www.youtube.com/watch?v=Z98Nz7O6vzs

Elasticsearch for Dot Net Developers - Dot Net Sheff - October 2018

https://www.youtube.com/watch?v=N83oReGA6vc

Introduction to Microservices, Docker, and Kubernetes

https://www.youtube.com/watch?v=1xo-0gCVhTU

Building Event-Driven Microservices with Event Sourcing and CQRS - Lidan Hifi

https://www.youtube.com/watch?v=XWTrcBqXi6s

When Microservices Meet Event Sourcing

https://www.youtube.com/watch?v=cISNDnwlSgw

Greg Young — A Decade of DDD, CQRS, Event Sourcing

https://www.youtube.com/watch?v=LDW0QWie21s

https://callistaenterprise.se/blogg/teknik/2015/04/10/building-microservices-with-spring-cloud-and-netflix-oss-part-1/

https://callistaenterprise.se/blogg/teknik/2015/04/15/building-microservices-with-spring-cloud-and-netflix-oss-part-2/

https://callistaenterprise.se/blogg/teknik/2015/04/27/building-microservices-part-3-secure-APIs-with-OAuth/

ASP.NET Core Full Stack

https://fullstackmark.com/post/21/user-authentication-and-identity-with-angular-aspnet-core-and-identityserver

https://ndccopenhagen.com/workshop/identity-access-control-for-modern-applications-and-apis-using-asp-net-core-2/

Data Transfer Objects (DTOs)

https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-5

ASP.NET MVC 5

https://nhatkyhoctap.blogspot.com/2012/08/aspnet-mvc-co-ban-ve-validation.html

https://nhatkyhoctap.blogspot.com/2013/03/su-dung-dependency-injection-trong.html

https://nhatkyhoctap.blogspot.com/2013/10/aspnet-mvc-authentication-va-authorize.html

ASP.NET Core Identity

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.2&tabs=visual-studio

Microservices security with OAuth2

https://piotrminkowski.wordpress.com/2017/12/01/part-2-microservices-security-with-oauth2/

Microservices security with Oauth2 (https://piotrminkowski.wordpress.com/2017/02/22/microservices-security-with-oauth2/)

Advanced Microservices Security with OAuth2 (https://piotrminkowski.wordpress.com/2017/03/30/advanced-microservices-security-with-oauth2/)

ASP.NET Membership > Asp.net Simple Membership> ASP.NET Identity

https://coding4food.net/2017/08/30/aspnet-identity-1-introduction/

OAuth và OpenID

https://www.codehub.vn/OpenID-va-OAuth-Khac-Nhau-Nhu-The-Nao

Đăng nhập & Phân quyền

ASP.NET

Free. Cross-platform. Open source. A framework for building web apps and services with .NET and C#.

ASP.NET Identity

The ASP.NET membership system was introduced with ASP.NET 2.0 back in 2005, and since then there have been many changes in the ways web applications typically handle authentication and authorization. ASP.NET Identity is a fresh look at what the membership system should be when you are building modern applications for the web, phone, or tablet.

ASP.NET Membership was designed to solve site membership requirements that were common in 2005, which involved Forms Authentication, and a SQL Server database for user names, passwords, and profile data. Today there is a much broader array of data storage options for web applications, and most developers want to enable their sites to use social identity providers for authentication and authorization functionality. The limitations of ASP.NET Membership's design make this transition difficult:

  • The database schema was designed for SQL Server and you can't change it. You can add profile information, but the additional data is packed into a different table, which makes it difficult to access by any means except through the Profile Provider API.
  • The provider system enables you to change the backing data store, but the system is designed around assumptions appropriate for a relational database. You can write a provider to store membership information in a non-relational storage mechanism, such as Azure Storage Tables, but then you have to work around the relational design by writing much code and a lot of System.NotImplementedExceptionexceptions for methods that don't apply to NoSQL databases.
  • Since the log-in/log-out functionality is based on Forms Authentication, the membership system can't use OWIN. OWIN includes middleware components for authentication, including support for log-ins using external identity providers (like Microsoft Accounts, Facebook, Google, Twitter), and log-ins using organizational accounts from on-premises Active Directory or Azure Active Directory. OWIN also includes support for OAuth 2.0, JWT and CORS.

https://docs.microsoft.com/en-us/aspnet/identity/overview/

ASP.NET Core

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

ASP.NET Core Identity

ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data.

Basically, you have two scenarios:

  • Either you're using ASP.NET Core, in which case you'll have to use Microsoft.AspNetCore.Identity.
  • Or you're using an ASP.NET version before ASP.NET Core, and you'll have to use Microsoft.AspNet.Identity.Core.

https://weblogs.asp.net/jeff/no-you-don-t-need-to-use-asp-net-identity

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?view=aspnetcore-2.2

https://andrewlock.net/introduction-to-authentication-with-asp-net-core/

.NET Developer và một số yêu cầu tuyển dụng

Cơ bản về lập trình OOP

Đây là điều bắt buộc các bạn phải biết trong khi đi phỏng vấn, các bạn không nắm vững cái này thì sẽ có khả năng cao là bị loại vì đây là những kiến thức hết sức căn bản. Để nắm chắc OOP tức là lập trình hướng đối tượng, các bạn cần nắm chắc khái niệm và các tính chất của nó (có 4 tính chất). Mỗi tính chất cac bạn phải hiểu và lấy ví dụ được đồng thời các bạn cũng phải nêu ra được tác dụng của nó.

Ngôn ngữ lập trình C#

Về ngôn ngữ lập trình C#, các bạn không cần thiết phải cái gì cũng biết nhưng một số điểm các bạn nên biết về Interface và Abstract class hay hiểu biết về các collection trong C#.NET. Ngoài ra các bạn cũng cần hiểu về đa luồng, extension methods, delegate, xử lý bất đồng bộ, overriding method, và tổng quan các thư viện hay dùng nhất.

ASP.NET MVC và WebAPI

Về ASP.NET MVC các bạn cần nắm rõ mô hình MVC là gì? Trong ASP.NET MVC có các thành phần gì? Cách truyền dữ liệu từ Controller về View có những cách nào? ViewBag, ViewData, TempData và  Session? Sự khác nhau giữa chúng như thế nào? Khi nào thì dùng cái nào?

Ngoài ra có cơ chế Routing, ASP.NET Identity, Antiforeign, WebAPI, kiến thức về REST và Restful API…

Entity Framework và ADO.NET

Câu hỏi hay hỏi nhất trong khi phỏng vấn .NET Developer là bạn đã làm việc với Entity Framework chưa? Có những cách làm việc nào? Vậy là các bạn phải trả lời được có 3 cách là DB First, Code First và Model First. Vậy là các bạn phải nêu được ưu nhược điểm của cả 3. Thường là DB First và Code First sẽ được hỏi nhiều nhất.

Một trong những câu hỏi hay được hỏi nhất về Entity Framework sẽ là phần Migration nếu bạn trả lời hay dùng Code First. Còn lại DB First thì các bạn cũng sẽ được hỏi những nội dung còn lại ngoài phần migration đó là phải hiểu về Linq to Entity tức là khi nào dữ liệu của bạn được load ra, dùng Iqueryable ra sao? Cách tối ưu hóa câu lệnh LinQ khi truy vấn database rồi cách phân trang bản ghi với LINQ.

Ngoài ra các bạn cần nắm được cách debug từ LINQ bản chất là gen ra câu lệnh SQL để execute trong SQL Server nên các bạn cần nắm được cách thức để debug, tracing và tối ưu hóa nó.

Đôi khi các dự án có làm ADO.NET có thể là call các store procedure trong SQL Server vì giờ không ai viết câu lệnh raw SQL trong code cả

Kỹ năng Unit Test

Đây là kỹ năng viết các đoạn code để kiểm thử ở mức đơn vị đối với các function code ra, trong .NET các bạn thường sử dụng MSUnit có sẵn của Visual Studio hoặc Nunit để viết các đoạn mã kiểm thử. Kỹ năng này không bắt buộc nhưng là điểm cộng của các bạn.

SQL Server

Về SQL Server ngoài việc viết lệnh CRUD thì các bạn còn phải tìm hiểu về Store Procedure, Triggers, Funtions, View đồng thời quan  trọng hơn là cách viết lệnh tối ưu, đánh index để tăng tốc độ cho câu lệnh.

Kỹ năng quản lý source code

Các bạn cần có kỹ năng quản lý source code khi làm việc với các SCM như Git hay SVN, TFS…để giúp làm việc nhanh và hiệu quả hơn.

Một số Design Pattern

Các bạn làm dev có thể không phải sử dụng nhiều vì các SA họ đã áp dụng đối với core của công ty nhưng các bạn nên biết để hiểu và tốt cho việc phát triển sự nghiệp của mình. Hơn nữa lên senior thì phải biết Design Pattern chứ nhỉ.

Principles

Các bạn cũng phải biết một số principle tiêu biểu là SOLID.

Kiến thức Frontend (Javascript, Jquery, Html, CSS, Angular ...)

Các bạn biết các kiến thức này mặc dù không phải là .NET nhưng nếu một công ty họ tuyển Fullstack developer thì những điều này giúp bạn tăng giá trị trong mắt nhà tuyển dụng.

Cách viết code sạch và tối ưu hóa code

Cách viết code sạch và tối ưu này mình rất coi trọng vì nếu các bạn làm junior hay senior thì việc các bạn viết Code nói lên chất lượng thực sự của các bạn. Kỹ năng này bao gồm việc đặt tên biến, tên hàm, class, cách viết code sao cho dễ đọc dễ maintenance …Giúp việc sử dụng lại code dễ dàng hơn nhất là khi các bạn làm một sản phẩm lâu dài thì nó lại càng hữu ích. Đây là một kỹ năng rất cần thiết và rất được các bậc tiền bối coi trọng.

Tóm lại

Là một .NET developer không chỉ biết code tốt, mà cần các kỹ năng liên quan nữa như thế mới thực sự có value. Hơn nữa code  tốt không bằng thái độ tốt, nhiều khi kỹ năng của bạn chưa được như người ta mong muốn nhưng thái độ của bạn khi phỏng vấn cũng làm người ta thấy mình có tiềm năng phát triển và có thể đáp ứng được công việc. Kể cả khi mình giỏi thật thì thái độ cũng phải khiêm tốn và cầu thị vì không ai giỏi tất cả. Cuối cùng là tư duy về sản phẩm, một developer giỏi không phải chỉ giỏi kỹ thuật mà phải hiểu khách hàng cần gì cũng đừng giới hạn mình theo những gì mình nói trong bài viết này mà phải mở rộng hơn nữa? Làm khách hàng hài lòng và làm sao để lợi cho khách hàng, lợi cho người thuê mình tức là lợi cho chính mình.

ban-can-chuan-bi-nhung-gi-truoc-khi-di-phong-van-vi-tri-net-developer-01

CQRS and Event Sourcing

September 16, 2018 23:14

CQRS and Event Sourcing (edit)

https://www.codeguru.com/whitepapers/using-command-query-responsibility-segregation-cqrs.html

SOLID

https://www.codeguru.com/csharp/.net/net_general/netframeworkclasses/solid-design-principles-with-implementation-in-c.html

SQL Server Transaction

https://www.codeguru.com/csharp/.net/net_data/handling-transactions-in-.net-using-transactionscope.html

Excel & Charts

https://www.codeguru.com/csharp/csharp/cs_misc/com/creating-excel-charts-in-c.html

DB Unit Test

https://www.codeguru.com/csharp/.net/net_data/create-sql-server-database-unit-tests-using-visual-studio.html

WinForms TabControl

https://www.codeguru.com/csharp/.net/net_asp/controls/adding-close-buttons-to-tab-pages-with-.net.html

Design time

Categories

Recent posts