What is the overhead when using Doctrine?

Asked

Viewed 223 times

3

A few days ago I was discussing with some colleagues about performance and high availability.

In the middle of the discussion one of the points raised was that when reaching a certain number of requests, the Doctrine ORM becomes a bottleneck in the application, and we would have to use PDO to maintain performance.

I could not accept the argument, since gigantic projects like Pornhub use Symfony with Doctrine and can meet a monstrous number of requests.

Not only are there projects that prove the efficiency of the library, there is a whole question of syntax and productivity involved. By using the ORM we are gaining a lot of productivity, as we avoid repetitive code that can lead to errors.

Given these facts, how can we correctly measure the difference of overhead in using the pure PDO and using the Doctrine ORM?

Important: Although the question is based on my experience of using the library, my goal is technical, therefore I wish to receive answers that demonstrate technically the advantage and disadvantage of using each tool.

  • 2

    Possibly "back-end cache" + "a series of lean servers".

1 answer

4


I do not believe that a library has only negative points, but also not only positive points.

When I see programmers making this kind of comment, I usually ignore it.

The important things to ask is: What is your experience to say this?

To show only the negative points of something is to be incoherent and partial.

I would also say that there is in some an eternal war of those who do not use frameworks or libraries wanting to converse who use to stop using, or vice versa.

The Doctrine

In my view, Doctrine is a fairly robust database framework that views, as stated in the question, avoiding code repetition.

What’s more, it has a relational model, which is often necessary for better organization of the access/registration of database data in your application - something that does not exist using PDO pure.

And the performance?

On the subject of performance, I have to say: Somehow you’ll have to pay for your choice.

If you choose to worry so much about performance to the point of not using Doctrine, you will have to do a lot at hand, or opt for another library, but then you would have to evaluate if the exchanges make up for the time spent.

On the other hand when choosing to use only the PDO, you’d be spending a lot of time remaking queries manually.

So weigh both things in the balance and decide which side you’re gonna be on.

I stopped worrying a long time ago about microtimization.

I think things should be weighed in the balance. It’s easy to say that a truck is too big to fit in a garage, but forget that it can carry a ton of things.

What I mean is that you have to evaluate whether your project will actually benefit from using an X or Y library.

One jargon I see among programmers, which I agree with, is : Why use a bazuka to kill an ant?.

I don’t think it would make sense to use Doctrine to make a simple website, which has only three tables for consultation. But if you’re going to do something more robust/scalable, I would highly recommend using it.

Completion

Some programmers may give opinions saying they can generate Overhead, but that was based on what?

What is the size of the application they have already developed? What is the scenario?

Pardon the joke, but any library you use will use more memory/resources in your application than if you didn’t use. But at the end of the day, without them, you’d have a whole bunch of stuff to write for your app.

Another detail: Some people tend to think something is bad, because they have misused the tool and, instead of admitting that they made a mistake, blame the framework (I myself have already made a mistake :) ).

What’s more, Doctrine is a framework (not to mention the only one) of the most robust PHP database I know.

Another detail is that if you think it doesn’t pay to use the Doctrine ORM, you can still use other resources, such as Doctrine Query Builder, which is a Doctrine queries builder that can also help prevent code repetition.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.