有一个网站的单一入口点.坏的?好的?没问题?

2021-12-21 00:00:00 php model-view-controller

这个问题源于观看 Rasmus Lerdorf 在 Drupalcon 上的演讲.顺便说一下,这个问题和他的演讲与 Drupal 没有特别的关系……它只是在他们的骗局中提出的.我自己的问题也与 PHP 无关.这是我很好奇的一般单一入口点.

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.

推荐答案

总之,Rasmus 或解释是错误的.

In short, Rasmus or the interpretation is wrong.

这表明显然缺乏对计算机工作原理的了解.使用的东西越多,它就越有可能离 CPU 越近,因此速度越快.请注意,单点进入!= 单点故障.但这并不是重点,当人们说单点入口时,我们指的是应用程序,它是您逻辑的单点入口.

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.

相关文章