"Enterprise Application Architecture" book review

1. Enterprise Application Architecture

  • Architecture

    • Definition of architecture: the highest level of system decomposition, the system is not easy to change parts.

    • The most valuable part of the framework are: hierarchical design.

  • The characteristics of enterprise applications

    • Typically involve persistent data

    • Typically involve large amounts of data

    • Usually it involved a lot of people to simultaneously access system

    • A large amount of data operation further relates to a user interface screen

    • Usually integrated with other enterprise applications around the enterprise

    • There is also the concept of data inconsistency

    • Complex business, "no logic"

    • Huge system must have "divide and conquer" mentality

  • The kind of enterprise applications (abstract, refining)

    • A large amount of data processing system

    • The user interface system demanding

    • Data Management System

  • Considerations for performance

    • Response time

    • Responsiveness: progress bar

    • waiting time

    • Throughput

    • load

    • effectiveness

    • Scalability

  • mode

    • The main mode is the "intention" and "Summary"

    • All models are abstractions behavior, are incomplete, need to learn to improve.

 

2. stratified

  • Professional people to do professional things

  • Benefits stratification

    • One layer may be an organic whole had to be understood

    • May be replaced with a inner layer is achieved, as long as the same service can be provided

    • Coupling may be reduced, to minimize the dependency of various levels

    • Layered in favor of standardization

  • Application-level corporate evolution

    • Three basic levels: the presentation layer, field layer, data layer source

 

3. Organization of business logic

  • Business logic model

    • Three modes: Transaction script, business model, table module.

    • Transaction script: a process control logic of an action.

    • Business model: Each object bear a part of the associated logic.

    • Table module: Table units designed pattern.

  • The business logic into the service layer, the service layer

    • Service layer: Place transaction control and security check, provide an easy to use API.

 

4. mapped to relational database

  • Architectural patterns

    • The main way of solving the logical drive field to access the database

    • The domain model and database completely independent, so that layer of indirection to complete the mapping between domain objects and database tables

  • Behavior problems

    • Reading data, and modify data from the database when the behavior of the action

    • The need to ensure data consistency

    • Lazy loading is also necessary idea, it is to have a major delay in loading the referenced object placeholder

  • Read data

    • Method of reading data can be seen as a finder

    • The key issue is to read data performance issues

    • Guidelines is possible to read data batch operation, to avoid repeated queries the same table

  • Structure mapping mode

    • Mappings: the mapping of objects and keys

    • Dependency mapping can simplify the mapping relationship

  • inherit

    • Single Table Inheritance: build a table of all classes

    • Concrete table inheritance: to create a table per concrete class

    • Class table inheritance: a level of each class to create a table

  • Establish a mapping

    • Mapping two steps: first program memory is converted into logical data storage scheme, and logical data stored in the physical data storage

  • Metadata

    • Metadata mapping: a database object to the domain map column.

  • Database Links

    • Build a large database link overhead, it is necessary to establish a connection pool

    • A transaction must ensure that each command is sent with a link

    • Links need to be closed after use, usually close links with the garbage collection mechanism

    • Avoid using select *, using precompiled mechanism to avoid sql injection.

 

5.Web presentation layer

  • web server application

    • Using a script: accept HTTP requests data output by the string written in the form of stream

    • Server Pages: program and return to the text pages together

    • The non-presentation logic stripped out

  • View Mode

    • Conversion view, a view template and two-step view

    • Switch view: a transformation program style

    • Template view: page written presentation layer structure, embedded in the page tag. However, this will lead to confusing code difficult to maintain.

    • Two Step View: front and rear ends can be understood as separate, two separate business logic clearer, but there is some loss in performance.

  • Input controller mode

    • Prepare a page a controller

    • The controller isolated single object, an action corresponding to a page.

 

6. Concurrent

  • Concurrency issues

    • Developers can simply avoid concurrency problems it is because the transaction manager.

    • Offline Concurrency: concurrency control operation of multiple database transaction data.

    • Lost update: First update data A 1, and then update the data B 1, and B before A complete update data. Then B will lead to updated data will be lost, since the beginning of B after A start, but ends before the end of the A, B leads A not read the update.

    • Inconsistency Read: A Read process data, B modifies the data, not the latest data A lead read.

  • Execution context

    • Request: single call external environment to deal with the issue of software work.

    • Session: long interactive client and server

    • Services: multiple requests seen as a single request

  • Isolated invariance

    • Locking the data

    • Identifying the same data

  • Optimistic and pessimistic concurrency control concurrency control

    • Optimistic locking: collision detection, application scenarios are less the result of the conflict and the conflict is not serious.

    • Pessimistic locking: collision avoidance, reduce the degree of concurrency, but will produce a large obstructive affect performance.

  • Avoid inconsistencies Reading

    • Pessimistic locking strategy is to read data plus a read lock (shared lock), write data plus a write lock (exclusive lock).

    • Optimistic locking strategy is the collision detection based on a version of tag data.

  • Deadlock

    • Pessimistic lock technology has a special problem is a deadlock.

    • Deadlock: A lock data plus 1, B 2 data, locking to the use of data if the latter A 2, B 1 to use the data. Because B 2 added to the data latch, B waits for executing the A and B need to wait for a data acquisition A executed. Thus between A and B appeared deadlock.

    • The method of processing a deadlock is detected and timeout control mechanism.

    • Try to avoid deadlock is the most effective solution: a start acquiring all locks, or to obtain a lock in the same order.

  • Affairs

    • ACID: atomicity, consistency, isolation, durability.

    • Long transactions: transactions that span multiple requests called long transaction.

    • Delayed transaction: open as late as possible transactions, transaction execution time can be reduced, but may result in inconsistent read.

    • Lock escalation: If a transaction is locked multiple rows of data, the database can not handle so many locks, it will escalate to a table lock.

    • Reduce transaction isolation: serializable, repeatable read, read committed and read uncommitted.

      • Serializable: completely isolated, serialized execution of all transactions.

      • Repeatable read: allow the phantom read, phantom read is added to batch A to a collection of elements, while B to read only part of the data. It is usually caused by the insertion of data.

      • Read Committed: re-read the data already submitted

      • Uncommitted Read: dirty reads are allowed, the read data is not submitted, but the data has been rolled back, and this situation is called a dirty read.

    • Business transactions and system transactions

      • System services: often said that the database transaction

      • Business Services: is a set of business operations, business also expect it to have ACID properties, the solution to this problem is complicated by off-line.

      • Offline Concurrency: the business transaction into a series of short transactions.

      • The biggest problem is a business transaction isolation.

  • Concurrency control mode is off-line

    • The preferred treatment is optimistic concurrency issues offline offline lock. Because it is easy to implement, it provides the best flexibility.

  • Concurrent application server

 

Guess you like

Origin www.cnblogs.com/wuchangliang/p/11129775.html