InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
PHP
Using an Accelerator in PHP
PHP

Using an Accelerator in PHP

InfinityCoder December 24, 2016

You want to increase performance of your PHP applications.

Use the Zend OPcache code-caching PHP accelerator to allow PHP to avoid compiling scripts into opcodes on each request.

PHP code accelerators do the bulk of their magic transparently by storing compiled versions of PHP scripts on disk or in shared memory in order to skip the compiling step with each request.
When the PHP engine is told to run a particular program, it reads the source code of the program and compiles it into a compact internal representation.

Then, it executes the instructions in that compiled representation. When it’s done executing the script, the engine throws away the compiled representation.
An accelerator, by contrast, keeps the compiled instructions around.

The next time the PHP engine gets a request to run the same program, the accelerator steps in and checks whether it’s saved a compiled version of that program.

If so, it tells the PHP engine to skip recompilation and just execute the already compiled version.

An accelerator can be configured to update its compiled representations based on different criteria, such as whenever the original program changes or only when you explicitly tell it to.

As of PHP 5.5, Zend OPcache is automatically built and installed. If you’re running an earlier version of PHP, install it from GitHub or PECL.
Though PHP 5.5 builds Zend OPcache, you still need to turn it on by editing your php.ini file to add a reference to the full path of the extension: zend_extension=/path/to/php/lib/php/extension/debug-non-zts-20121212/opcache.so.
Although you should see a large improvement immediately, you can further improve performance with additional tuning.

As a start, update your production configuration parameters to:

1
2
3
4
5
6
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

Ultimately, the “right” settings are a balance of factors that depend on the size of the code, how frequently it changes and is called, the amount of memory on your system, and so on.

You will need to experiment and use a stress-testing tool to see what’s ideal for your specific system.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Creating a Resource in PHP
You want to let people add a new resource to …

Creating a Resource in PHP

Calling Variable Functions in PHP
You want to call different functions depending on a variable’s …

Calling Variable Functions in PHP

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

  • fer on Turning a Dictionary into XML in Python
  • mahesh on Turning a Dictionary into XML in Python

Categories

  • Bash
  • PHP
  • Python
  • Uncategorized

InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

About Us

Start learning your desired programming language with InfinityQuest.com.

On our website you can access any tutorial that you want with video and code examples.

We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

Popular Tags

binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

Archives

  • June 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
Copyright © 2021 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
Programming Tutorials | Sitemap