Summary: Learn + Work (2020.03)

1, the code of the transaction database operations sequentially

  Preferably query, delete, add code to start operation in the transaction, will be modified in local affairs to a close.

  Because the amendment involves locking the data (gap lock), so in order to lock the data as much as possible for a short time, to modify the transaction should be placed near the end position.

2, create objects related issues

  Before watching JVM courses that create objects can be written as User user = null; can then be assigned to the user where in the code logic. But there will be a problem if the user is not assigned, and the object of direct field assignment, will be reported null pointer exception. (The actual experience writing code, try catch in, try returns a user instance of an object, catch in direct capture service exception, not user objects, and user.setName () Similar operations will be reported null pointer exception)

  So after creating an object, or write User user = new User (); do not write User user = null;

 

Reconstruction of learning knowledge

3, micro-services deployment

  Examples nacos as to register / distribution center, in the same register in different IP to nacos, is a plurality of instances. For example, the two hosts have registered with a User on a project to nacos center, there are two User instance. ribbon load balancing in the micro-service applications, the default is access to polling.

  If nacos Register / distribution center has several, the formation of clusters of micro services.

4, split micro services

  The split out the common function part, called lateral resolution, allows the downstream shared across other widgets.

  The degree of polymerization by split function, called the longitudinal split, so that display data from the database into the pages in the same micro interaction service.

  Problem of micro-services in an isolated situation there, but it is especially in the case of micro-distributed service.

  Interface call you need to register with the service discovery, service call;

  Interface error would need to downgrade and fusing process;

  Interface performance is required expansion;

  Interface calls the situation needs to be monitored;

  Troubleshooting needs to link the whole track.

5, micro-assembly services

  Registration Authority:

    Service provider services heartbeat micro registry is to use http request to inform the registry.

    If you have registered provider to add or delete nodes, to ascertain the registry, it is necessary to push the consumer service, then refresh the cache in the local registry list.

    Node node test environment and development environment, you can dynamically modify the specified environment directly at the time of deployment. For example, although the code point to dev environment, but can be specified test environment deployment. This operation is dynamically changed by the args parameter of the main method springboot.

    Registration centers are generally clustered deployment, then it comes to consistency. So the registry itself will have the consistency of operations.

  RPC calls:

    To consider the richness types of supporting data structures, cross-language support, performance and readability (compressed data requires less bandwidth and faster).

  monitor:

    Request and response time is an important indicator of the health of the interface reaction.

  Governance means:

    Load balancing is achieved ribbon do, nacos only dynamic configuration algorithm is passed to the algorithm set of ribbon as a dynamic parameter.

6, the use of micro-service basis points

  In the actual project, a service call may supermarket, then we need  to retry to ensure the success rate call. But here also it relates to an idempotent . (Idempotence can use pessimistic locking, optimistic locking, database fields to achieve a unique index, etc.)

  Registration centers need to take into account two points: high availability (clustering, multi-IDC deployment), consistency .

 

Guess you like

Origin www.cnblogs.com/AlmostWasteTime/p/12598096.html