1

I am optimizing a Zend Framework based application, and I am sure using ini based config slows down overall performance as the sites need to read and parse ini on each and every page request. Now I have 2 ideas to deal with the situation

  • Cache the ini file or cache the zend_config object and use it from cache
  • Or convert the ini based config to php

I am not sure which approach provides better performance. I will be modifying the configuration my self in future if needed, and I don't need the feature of writing config back to the ini. So please suggest which approach is better for extreme performance. In cache approach its just deserializing an already existing object, while in php array its constructing object from scratch.

Bryan
  • 645
  • 1
  • 6
  • 18

2 Answers2

0

Cache!

Explanation:

If you convert it to a php Object you merely exchange the parser, and mind: PHP has many constructs, and building a AST is not even remotely simple for this language.

With a cache your data will likely be stored in Memory and so your HardDisk will not have to perform any I/O to get the settings object each request. Even parsing or deserialization can be handled a lot quicker that way, and remember this will also be done by the PHP Interpreter.

A last Hint:

If you are afraid your ini files parse too long, maybe you could slice your config file and, and not always load all settings?

FloydThreepwood
  • 1,587
  • 14
  • 24
  • what about using some opcode caching or accelerators for php. I think they will also cache the php file contents. and in that case which approach is faster deserializing an already existing object or using a php array to construct an object from scratch. – Bryan Oct 26 '11 at 23:16
  • Serializing Objects is implemented by Magic Methods, ZendEngine has to perform a lookup for them. This is therefore less performant than a construct via array. Opcode caching is a good call, but remember it does much less matter in wich format you cache your data, than it matters where it is stored! Memory will almost allways outspeed HDD stored cache (unless there is a serious bug in your tool ;) ). Good Luck! – FloydThreepwood Nov 02 '11 at 11:53
0

Cache the ini file or cache the zend_config object and use it from cache

this is the right choice.

check this application.ini cache

sas
  • 2,563
  • 1
  • 20
  • 28