Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
439 views
in Technique[技术] by (71.8m points)

php - What is the Symfony firewall doing that takes so long?

My Symfony page isn't too slow (it loads in about 400 ms) but considering the fact that it's just a simple hello world page with basic authentication, it should be loading in less than 100 ms. When I enter the profiler, I see this:

Profiler timeline

Notice it just says "Firewall" for 250 ms. I thought the firewall was just responsible for keeping users out of certain areas of the page - I can't imagine that taking any longer than a few milliseconds plus the time it takes to fetch the user information from the database (which in this case is 61 ms).

Could somebody explain what the firewall actually does? If you have any general pointers on how to increase the firewall performance as well that would be greatly appreciated.


Note: I have Googled this of course, and I want to specify up front that I'm connecting to the MySQL database by IP address, not host name. This seemed to be the issue for every other case of slow Symfony firewall I could find.


Some resources from my project that could be relevant:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I did some googling and I see that this guy, seems to have the answer to your question.

After 15 minutes of research I ended up figuring out that this was due to the PHP PDO constructor (my Firewall is the first to connect to the database as I use Entities as users). With this knowledge the issue was pretty quickly found ([1], [2]): as it turns out using a DNS name (like 'localhost') instead of an IP (like '127.0.0.1') causes this issue.

A simple edit of the parameters.yml file (changing localhost to 127.0.0.1) did the trick of reducing the Firewall load time to only a minimum.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...