General Concept CPU Core Caching Cache Lines Cache Memory Associative Memory Direct-Mapped Memory Set Associative Memory Cache Read/Write Policies cache coherency MESI protocol: (Modified, Exclusive, Shared, Invalid) * Invalid lines are cache lines that are either not present in the cache, or whose contents are known to be stale. For the purposes of caching, these are ignored. Once a cache line is invalidated, it’s as if it wasn’t in the cache in the first place. * Shared lines are clean copies of the contents of main memory. Cache line
Read more »

Where is my cache for a service [Architectural Patterns for Caching Microservices](Architectural Patterns for Caching Microservices) Patterns: 1. embedded: save cache in the service 2. client-server: a completely separate cache server 3. reverse-proxy: put the cache in front of each service 4. Sidecar: put the cache as a sidecar container that belongs to the service How does cache work? The application receives the request and checks if the same request was already executed (and stored in the cache) Embedded Embedded Distributed Cache Why distributed? 1. Same requests happen on diff
Read more »

Symptoms You may receive the following error message when you create a FOREIGN KEY constraint: (microsoft report) 1 Server: Msg 1785, Level 16, State 1, Line 1 Introducing FOREIGN KEY constraint 'fk_two' on table 'table2' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Server: Msg 1750, Level 16, State 1, Line 1 Could not create constraint. See previous errors. For example, the table definition is like this: 1 2 3 4 5 6 7 8 Table t1: Id: primaryKey Table t2: Id: primaryKey parent: Fore
Read more »

playing-nhibernate-inverse-and-cascade, nhibernate-inverse bidirectional associations In database, there may be biodirectional relationships, e.g. Parent has multiple child, and Child has a parent. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #### class definition class Parent: - String id - IList childs class Child: - String id - Parent parent #### db definition table Parent: - id table Child: - id - parentId Inverse Inverse focus on the association. It defines which side is responsible of the association maintenance (create, update, delete), that is, the
Read more »

the great video History Why does we create internet? It’s created from the need of American military, to protect the communication in the wars. The old communication system, phone, connects Lily with Tom through fixed central offices. If some of the central offices are destroyed by nuclear, then the rerouting of the communication line is difficult, that the commnunication will fail. Ta Da.. Internet comes. It communicates through millions of routers. Even half of the routers are destroyed, there may still be the way to communicate. Why does we create VPN (virtual private network)? Interne
Read more »

nginx 502 和 504 超时演示 502 Bad Gateway: The server was acting as a gateway or proxy and received an invalid response from the upstream server. 504: he server was acting as a gateway or proxy and did not receive a timely response from the upstream server. Conclusion 504 是 nginx 没有及时从上游服务获取响应,超时了: * 上游服务响应慢,读取 response / 发送 request 超时(upstream timed out (110: Operation timed out) **while** reading response header from upstream) * 某些请求处理就是慢。此时就应该调大 proxy_read_timeout (默认 60s) * 上游服务压力太大,响应变慢。此时可以增加上游服务的响应能力,也可以适当提升 proxy_send_timeout, proxy_read_timeout * 连接上游服务超时。可能是上游服务已经断了,但由于
Read more »

What’s MaxDOP MaxDOP(max degree of parallelism) is an option to limit the number of processors to use in parallel plan execution. For a single query you asked to sql server, it may use multiple worker threads to process it (each query in fact contains many operations internally). The MaxDOP limit the concurrency in that case. What’s the proper value? By default, it’s 0, which means no limit, and sql server may use all the processors it has to process a query. MaxDOP = 1 When setting it as 1, you alwase process the query sequentially. You suppress the parallel plan generation. Why? While thi
Read more »

yield is a contextual keywords. When it shows in a statement, it means the method or get accessor in which it appears is an iterator. Thus it provides a simple way to define an iterator, rather than a class that implements IEnumerable or IEnumerator. When you use the yield contextual keyword in a statement, you indicate that the method, operator, or get accessor in which it appears is an iterator. Using yield to define an iterator removes the need for an explicit extra class (the class that holds the state for an enumeration, see IEnumerator for an example) when you implement the IEnumerable
Read more »

FluentValidation Knowledge * The RuleFor method create a validation rule. To specify a validation rule for a particular property, call the RuleFor method, passing a lambda expression that indicates the property that you wish to validate. * Rules are run syncronously By default, all rules in FluentValidation are separate and cannot influence one another. This is intentional and necessary for asynchronous validation to work. * Must, NotNull…. are built-in validators. WithMessage is a method on a validator. When defines condition for validator(s). * Append multiple validators on a same
Read more »

.net, asp.net, c# c# is like java language specification; .net is like jdk/javase/javaee asp.net: is like springboot 1. default, as, is 2. sln: solution ——> csproj: c sharp project ——> files .sln vs .csproj Key concepts ref: c# concepts * solution: a complete application, similar to maven project. It contains several c# project like frontend, backend, library to compose a complete application. * project: similar to maven module. It can be a web project, a library, a windows program, etc. * assembly: similar to maven jar. A c# project is corresponding to an assembly. An assembly can b
Read more »
0%