PHP enables opcache to improve Code Performance

Source: Internet
Author: User
Tags apc

PHP enables opcache to improve Code Performance

PHP enables opcache to improve Code Performance

APC is the best-performing code cache in PHP5.4 and earlier versions. However, after PHP is upgraded to 5.5 or above, APC is no longer valid. The Zend OpCache extension is required.

The configuration command is as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

[Opcache]

Zend_extension = opcache. so

Opcache. enable_cli = 1

; Shared memory size, which can be adjusted according to your needs

Opcache. memory_consumption = 256

; Interned string memory size, also adjustable

Opcache. interned_strings_buffer = 8

; Maximum number of cached files

Opcache. max_accelerated_files = 4000

; Check for file updates every 60 s

Opcache. revalidate_freq = 60

; Enable quick close. Enabling this will increase the memory receiving speed when the PHP Request Shutdown is enabled.

Opcache. fast_shutdown = 1

; Do not save file/function comments

Opcache. save_comments = 0

Actual Performance Comparison:

The following figure shows that opcache is not enabled in actual tests:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

[Root @ localhost ~] # AB-n 10000-c 200 "http: // 112.126.69.14/main. php? A = Role & m = createRole"

This is apachetings, Version 2.3 <$ Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

 

Benchmarking 112.126.69.14 (be patient)

Completed1000 requests

Completed2000 requests

Completed3000 requests

Completed4000 requests

Completed5000 requests

Completed6000 requests

Completed7000 requests

Completed8000 requests

Completed9000 requests

Completed10000 requests

Finished 10000 requests

 

Server Software: openresty/1.7.2.1

Server Hostname: 112.126.69.14

Server Port: 80

 

Document Path:/main. php? A = Role & m = createRole

Document Length: 2 bytes

 

Concurrency Level: 200

Time taken for tests: 26.061 seconds

Complete requests: 10000

Failed requests: 20

(Connect: 0, Receive: 0, Length: 20, Exceptions: 0)

Write errors: 0

Non-2xx responses: 20

Total transferred: 1713580 bytes

HTML transferred: 23520 bytes

Requests per secondd: 383.72 [#/sec] (mean)

Time per request: 521.216 [MS] (mean)

Time per request: 2.606 [MS] (mean, internal SS all concurrent requests)

Transfer rate: 64.21 [Kbytes/sec] canceled ed

 

Connection Times (MS)

Min mean [+/-sd] median max

Connect: 2 3 3.2 2 60

Processing: 17 461 905.0 219 16496

Waiting: 17 461 904.9 219 16496

Total: 21 464 905.0 222 16502

 

Percentage of the requests served within a certain time (MS)

50% 222

66% 271

75% 369

80% 412

90% 805

95% 1248

98% 2597

99% 3489

100% 16502 (longest request)

Data After enabling:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

[Root @ localhost ~] # AB-n 10000-c 200 "http: // 112.126.69.14/main. php? A = Role & m = createRole"

This is apachetings, Version 2.3 <$ Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

 

Benchmarking 112.126.69.14 (be patient)

Completed1000 requests

Completed2000 requests

Completed3000 requests

Completed4000 requests

Completed5000 requests

Completed6000 requests

Completed7000 requests

Completed8000 requests

Completed9000 requests

Completed10000 requests

Finished 10000 requests

 

 

Server Software: openresty/1.7.2.1

Server Hostname: 112.126.69.14

Server Port: 80

 

Document Path:/main. php? A = Role & m = createRole

Document Length: 2 bytes

 

Concurrency Level: 200

Time taken for tests: 14.237 seconds

Complete requests: 10000

Failed requests: 0

Write errors: 0

Total transferred: 1711710 bytes

HTML transferred: 20020 bytes

Requests per secondd: 702.40 [#/sec] (mean)

Time per request: 284.739 [MS] (mean)

Time per request: 1.424 [MS] (mean, internal SS all concurrent requests)

Transfer rate: 117.41 [Kbytes/sec] canceled ed

 

Connection Times (MS)

Min mean [+/-sd] median max

Connect: 2 66 272.6 2 3005

Processing: 4 176 666.4 6 9026

Waiting: 4 163 642.8 6 9026

Total: 6 242 745.7 9 10028

 

Percentage of the requests served within a certain time (MS)

50% 9

66% 14

75% 99

80% 122

90% 1006

95% 1476

98% 2853

99% 3543

100% 10028 (longest request)

The above is all the content of this article. I hope you will like it.

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.