Recently, I have been studying server performance optimization and highly concurrent request access. I have investigated unstructured data (nosql) and memory acceleration (cache), and re-designed the old platform services, we strive to save 10000 USD per month.
Research projects include redis, memcached, MongoDB, and Amazon dynamodb.
RedisIt is an open-source log-type and key-value database written in ansi c language that supports the network and can be persistent based on memory. It also provides APIs in multiple languages. At present, VMWare hosts the development work.
1) Data Model
As a key-value database, redis also provides a ing relationship between keys and values. In addition to common values or strings, The redis key value can also be one of the following forms:
Lists (list)
Sets)
Sorted Sets)
Hashes)
The data type of a key value determines the operations supported by the key value. Redis supports advanced atomic operations such as list, set, or sorted set intersection, union, and difference set. If the key value type is a common number, redis provides auto-increment and other atomic operations.
2) Persistence:
Redis usually stores data in memory or is configured to use virtual memory.
Data persistence can be achieved through two Methods: Using snapshots to constantly write data in the memory to the disk; or using a log method similar to MySQL to record the log of each update. The former has high performance, but may cause a certain degree of data loss; the latter is the opposite.
3) Performance synchronization:
Redis supports synchronizing data to multiple slave databases. This feature is very helpful for improving reading performance. Compared to databases that need to record each update on a disk, the memory-based features undoubtedly bring excellent performance to redis, and there are significant performance differences between read/write operations.
4) API Language
Supports C, C ++, C #, Java, JavaScript, Lua, objective-C, Perl, PHP, Python, Ruby, and go. For more information, see the official redis website.
-------------------------------------------------------
MemcachedIs a high-performance distributed memory object Cache System for dynamic web applications to reduce database load. It caches data and objects in the memory to reduce the number of times the database is read, so as to provide dynamic, database-driven website speed. Memcached is based on a hashmap that stores key/value pairs. Its daemon is written in C, but the client can write it in any language and communicate with the daemon through memcached protocol.
1) event handling
Memcached uses the libevent library to provide high performance in Linux, BSD, Solaris, and other operating systems. Libevent is a library that encapsulates the epoll, kqueue, and other event processing functions of Linux operating systems into a unified interface.
2) Data Storage
To improve performance, data stored in memcached is stored in the memory storage space built in memcached. Because the data only exists in the memory, restarting memcached and the operating system will cause all data to disappear. In addition, when the content capacity reaches the specified value, the unused cache is automatically deleted based on the LRU (least recently used, least recently used) algorithm. Memcached itself is a server designed for caching, so it does not take the permanent data into consideration.
3) API Language
Supports C, C #, C ++, Java, Perl, PHP, Python, Ruby, Lua, and other languages. For more information, see memcached clients.
--------------------------------------------------------
MongoDBIs a distributed file storage-based database written in C ++, designed to provide scalable high-performance data storage solutions for Web applications.
The MongoDB server can run on Linux, windows, or IOS platforms. It supports 32-bit and 64-bit applications. The default port is 27017. It is recommended to run on a 64-bit platform, because MongoDB supports a maximum file size of 2 GB when running in 32-Bit mode, while a 64-bit platform is very large.
MongoDB is a product between relational databases and non-relational databases. It has the most abundant functions and features like relational databases. The supported data structure is very loose and is similar to the JSON bson format, so it can store more complex data types. The biggest feature of Mongo is that it supports a very powerful query language. Its syntax is somewhat similar to an Object-Oriented Query Language. It can almost implement most of the functions similar to single-table queries in relational databases, it also supports data indexing.
1) Features: High Performance, easy deployment, easy to use, and easy to store data
2) function: This function is designed for centralized storage and is easy to store object-type data. It supports dynamic queries, full indexing, and internal objects. It supports replication and fault recovery. It uses efficient binary data storage, including large objects (such as videos); automatic fragment processing to support cloud computing-level scalability
3) format: the file storage format is bson (a json extension), which can be accessed through the network.
4) API languages: C, C #, C ++, Java, JavaScript, PHP, Ruby, Python, Perl, etc. For more information, see MongoDB home.
Reference recommendations:
Redis memcache comparison (experimental data)
Comparison between memcache and redis
Comparison between redis and memcached (official)
About MongoDB, redis, memcache (csdn)