Memories of database optimization and Memacache distributed cache, memacache Cache

Source: Internet
Author: User
Tags database sharding

Memories of database optimization and Memacache distributed cache, memacache Cache

 

 

Horizontal database sharding
1. Store database files on different disks to make full use of disk io
Table Partitioning
1. Table databases can be partitioned.
Partition by date
Partition by condition
Active partitioning
1. Place historical data in the History Table
The current table only contains three days of data.
(Tables with a large volume of data can be processed)
Vertical database shard
Divides data into multiple databases based on business modules
All user-related data is stored in the user database.
Order-related data are stored in the order database...
(Advantage: pressure distribution ,)
Database Cluster: read/write splitting
(One master database and multiple slave databases. (MySpace once did this and can support millions of accesses ))
Continue optimization, multi-master database, and multi-slave database (prevent master database from being crashed, and data synchronization problems: mysql has dedicated configuration, which can be used with a third-party solution for latency)

Solve disk IO with Cache


 
Memacahce cluster Principle
1. The cluster is implemented through the client driver

Memacache: disadvantages
Cannot be used as persistent storage of data
Data storage restrictions: cannot exceed 1 MB
Key-value storage only
There is no replication and synchronization mechanism for cluster data, and no master-slave replication mechanism. If a node breaks down, it will affect the overall performance (it also improves performance) (the crash will not affect the program)
Memory recovery is not timely
Lru algorithm (inert deletion) unused memory, expired memory, minimum recently used memory

(Expired memory: There is an expiration time when the key is added)


Memacache + cookie (Alternative session) Perfect solution

Change write | change read

Assign a unique guid
Use it as the key of the mm, put the object to the value of mm, and put the guid to the cookie.
String userLoginID = Guid. NewGuid (). ToStrig ();
Response. Cookies ["aa"]. Value = userLoginID;

Request. Cookies ["aa"]. Value;
(Before using this method, you must determine whether the Request. Cookies ["aa"] are empty and empty. If you click "Value", the system will definitely return an error in null reference)


// Sliding expiration time:
Is to add a period of time,
Delete the remaining expiration time, and then append a new expiration time to it.



Write memacache cache (help class)
Write to local cache write to mm write to redies... (there is a change point [observer mode])

Sliding Window expiration Mechanism

July 7, 2017 16:30:43

Static Property: dependency Injection
There will be a value Once injected
Replace applicationstart as its object
Or assign a value to the constructor.
OK. The problem is fixed.


Note: [Serializable] Must be serialized when mm is used.


Modify the tt template to search for partial class

\ R \ n give it a carriage return line break
Then add a serialization above it
OK.


After one and a half years of netmvc development, the business logic is really not very good, but I realized that the technical breadth has reached the three-year coding level. I am very pleased that I am currently doing research on RN, have time to sit on the webapi interface, have time to write the structure, study the scalability and maintainability of the software, and occasionally look at high concurrency ..., very good. Now I am mainly engaged in mobile App development. If you have any channels, you can discuss it with me. Myself: jkxx123321





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.