PHP5.5 serialization performance comparison, php5.5 serialization

Source: Internet
Author: User

PHP5.5 serialization performance comparison, php5.5 serialization

Three serialization methods, json_encode, serialize, and igbinary, have been tested before. PHP5.5 has not been tested yet. This test is based on PHP5.5 and is a test case,
Http://blog.csdn.net/hguisu/article/details/7651730
The test cases are the same, but from this test home igbinary serialize test, as a comparison, you can refer
Http://www.ooso.net/archives/538

Running Environment
PHP5.5 memory 16G 8 core 2.0 GMHz

Performance & Space size list

Test results using a small array

json :156serialize :222igbinary_serialize :123json_encode :0.02264404296875json_decode :0.052916049957275serialize :0.031183004379272unserialize :0.029985904693604Igbinary Serialize: 0.024919986724854Igbinary unSerialize: 0.019716024398804

To facilitate the comparison, put the test results of PHP5.3 below (igbinary was not tested before)

json :156serialize :222json_encode :0.1087498664856json_decode :0.12652111053467serialize :0.041656017303467unserialize :0.040987968444824

Test results using a large array

json :5350serialize :8590igbinary_serialize :2432json_encode :0.92639899253845json_decode :1.8222811222076serialize :1.3030271530151unserialize :1.1492691040039Igbinary Serialize: 0.95630598068237Igbinary unSerialize: 0.82603001594543

The following are the previous results (igbinary was not tested before)

json :5350serialize :8590json_encode :0.90479207038879json_decode :1.753741979599serialize :1.3566699028015unserialize :1.3003630638123

Summary:
Data:
1: After being upgraded to PHP5.5, The json, serialize, and igbinary formats are serialized without changing the size. This means that the object structure of these three formats has not changed, so they can be upgraded seamlessly.
2: In terms of space occupation, igbinary has obvious advantages in space saving. For example, for data of 8.6 k size in an array of json, The serialize method requires 2.4 k, while the igbinary method requires only k, almost 1/4 of the serialize mode.
Performance
1: For small data volumes, the performance of json and native serialize is improved compared with that of PHP5.3, while the performance decreases when processing large data volumes.
2: In terms of serialization, json_encode has the best performance, followed by igbinary. The two are almost the same, and the worst is native serialize. Native serialize consumes about 1.4 times the performance of json and igbinary.
3: In terms of deserialization, igbinary is faster than the serialization process. Of course, it is also the fastest, but this speed is also costly. For more information, see the final considerations.
4: Overall Performance Comparison: The overall performance is the sum of serialization and deserialization. simple comparison shows that json is the worst, followed by native serialize, and ibinary is the best way.

ComprehensiveWhether in terms of serialization performance or occupied space, igbinary is the best choice. However, using igbinary_unserialize is not free of charge. During the test, we found that when the igbinary_unserialize is called, passing illegal data will cause the entire php process to die.

child 19131 exited on signal 11 (SIGSEGV) after  1.844938 seconds from start 1.844938 seconds from start
It is estimated that in order to improve the performance of igbinary, no format verification is performed during unserialize, causing the entire process to exit unexpectedly. When using Redis, we first use the SERIALIZE_PHP Method for serialization. To improve performance and reduce the waste of Redis space, we use the igbinary_serialize method. When switching, we accidentally step on this pitfall, this causes an error in the server response, which is directly 502, thanks to the daily environment.

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.