What's In A Name?

In this short video we cover a best practice I stick to when specifying the database_host in Doctrine's configuration.

I always use the IP address of the database server - primarily due to there being one less process to go through when Doctrine is communicating with the underlying database - i.e. no name resolution.

This comes from a couple of types of Stack Overflow issues I have seen over the last couple of years - but have to say, I haven't experienced myself first hand.

The first is that as above, name resolution can add an additional overhead to the process. If specifying an IP address directly will remove this problem before it even emerges, then why not do this before problems occur?

Secondly, I have seen issues whereby connectivity to the database itself isn't even possible when using a named host. As I say, I haven't encountered this myself, but again, if specifying the IP address is a quick solution to a problem I don't want to have, then why not just specify it ahead of time, and be done with the problem?

So there you go. It might seem obvious, but if my experience is anything to go by, the obvious is usually the one thing you overlook when troubleshooting, and instead spend 4 hours diving deep into some obscure technical arcana when simply turning it off and on again would have sufficed.

Code For This Course

Get the code for this course.