Apache vs. LightHttp: função echo

Na versão em inglês do meu blog recebi um comentário estes dias que me deixou, “boiando”. No artigo sobre RSS onde eu apenas echoava o conteúdo do RSS usando a função “echo” do PHP. O usuário “BrokenToy” relata que teve alguns problemas utilizando a mesma solução no servidor Lighthttp, pois um “lixo” sempre aparecia no final do arquivo, evitando a validação do XML.

Até ai tudo bem, alguma imcompatibilidade estranha que ainda estou para estudar, mas depois ele relata uma forma diferente de jogar o conteudo na tela, usando “php://output”, e relatando que a função echo tinha diferenças de performance.

Fiquei com uma pulga na orelha e hoje pela manha esbarrei em um post que relata o mesmo. Tobias Schlitt relata um um post que entre o Apache e o Lighthttp existe uma diferença, pequena mas impactante, na performance do comando echo. Aparentemente um echo que demore 0.001 no Lighthttp, pode demorar 0.004 no Apache.

Comparação de Performance (Fonte: Tobias Schlitt)

Tobias relata que a única resposta que lhe pareceu válida sobre o assunto é o fato de o Lighthttp usar a memória compatilhada para transferência de dados, e o Apache “alguma outra coisa”. Bem a tese esta sendo discutida em listas de discussão, quem sabe em breve não teremos uma resposta concreta.

comments powered by Disqus

Related Posts

PHP Community: Of Leaders, conferences and Union

PHP Community: Of Leaders, conferences and Union

  • February 24, 2012

Note: This article was originally published on the march/2011 issue of php-architect. If you like it keep a close eye on the Community Column in the magazine, where i get the chance to write alongside other awesome community people.

Read More
Pequenas mudanças

Pequenas mudanças

  • August 23, 2008

Caro leitor frequente,

Você que acompanha este blog desde seu início, em 2006 percebeu que ele sempre rondou em torno de assuntos web, mas sempre com um foco em PHP. A hora chegou e este blog irá tomar alguns novos rumos, desta forma acredito que poderei escrever novos artigos de novos assuntos e manter um repertório maior e muito mais interessante.

Read More
PHPT: Writing tests for PHP

PHPT: Writing tests for PHP

  • August 23, 2009

This year the PHP Community promoted the PHPTestFest in various places around the globe and it was a success. I participated in the event promoted by the PHPSP UG which ended up as the team with the most committed tests, after participating in the event I kept on going and have since obtained a SVN account and karma to be a official test commiter to PHP. So if you did not get the chance to learn how to write tests in your local TestFest I will now go over the steps taken so you can be ready for next year.

PHPT is a extremely simple test framework designed to test PHP. Its atomic nature and independent test execution make it perfect for the kind of tests needed, so tests can be really focused and test specific function and/or bugs.

What do I need to know?

The beauty about PHPT is that you need to know very little other than writing PHP code. A little knowledge into the inner workings of PHP will of course help you in finding areas of code that need testing, and how best to test them, but just knowing PHP is enough to start.

I have divided this post into 5 parts so we can get started:

  1. Preparing the Environment
  2. Choosing what to test
  3. Writing a test
  4. Executing a test
  5. Submitting a test to PHP

Read More