Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having a single entry point to a website. Bad? Good? Non-issue?

This question stems from watching Rasmus Lerdorf's talk from Drupalcon. This question and his talk have nothing specifically to do with Drupal, by the way... it was just given at their con. My own question also has nothing specific to do with PHP. It is the single entry point in general that I am curious about.

These days it seems that most frameworks offer a single entry point for whatever you build with them. In his talk Rasmus mentions that he thinks this is bad. It seems to me that he would be correct in this thinking. If everyone hitting the site is coming in through the same entry point wouldn't things bog down after traffic reached a certain point? Wouldn't it be more efficient to allow people direct access to specific points in a site without having their request go through the same point? But perhaps the actual impact is not very bad? Maybe modern architecture can handle it? Maybe you have to be truly gigantic in scale before it becomes even worth considering? I'm curious as to what people on this site think about this issue.

like image 747
rg88 Avatar asked Mar 02 '09 21:03

rg88


3 Answers

In short, Rasmus or the interpretation is wrong.

This shows a clear lack of understanding how computers work. The more something gets used, the more likely it's closer to the CPU, and therefore faster. Mind you, a single point of entry != single point of failure. But that's all beside the point, when people say single point of entry, we're talking about the app, it is a single point of entry for your logic.

Not to mention it's architecturally brain-dead not to have a central point of entry, or reduce the number of entries points in general. As soon as you want to do one thing across your app at every entry point, guess how many places need to change? Having dealt with an app that each page stood on it's own, it sucked having to change, and I assure you, we needed it.

like image 95
Saem Avatar answered Nov 04 '22 00:11

Saem


The important thing is that you use a web framework that supports scalability through methods like load-balancing and declarative code.

No, a single-entry point does not in itself make a bottleneck. The front page of Google gets a lot of hits, but they have lots of servers.

So the answer is: It doesn't matter.

like image 4
Jason Cohen Avatar answered Nov 04 '22 02:11

Jason Cohen


Like anything in software development, it depends. Rasmus's objection to the front-controller style frameworks is the performance hit you take from having to load so much code up-front on each request. This is 100% true. Even if you're using a smart-resource loading module/object/etc of some kind, using a framework is a performance trade-off. You take the performance hit, but in return you get back

  1. Encouraged seperation of "business logic" (whatever that is) and Template/Layout Logic

  2. Instant and (more importantly) unified access to the objects you'll use for database queries, service called, your data model, etc.

To a guy like Rasmus, this isn't worth the performance hit. He's a C/C++ programmer. For him, if you want to separate out business logic in a highly performant way, you write a C/C++ Extension to PHP.

So if you have an environment and team where you can easily write C/C++ extensions to PHP and your time-to-market vs. performance ratio is acceptable, then yes, throw away your front-controller framework.

If that's not your environment, consider the productivity increases a front-controller framework can bring to your (likely) simple CRUD Application.

like image 4
Alan Storm Avatar answered Nov 04 '22 01:11

Alan Storm