简体   繁体   English

通过网址界面与包含功能

[英]Functionality via Url Interface vs. Include

I have been working on a project which had been split over several servers and so php scripts had been run through a url interface. 我一直在研究一个项目,该项目已拆分为多个服务器,因此php脚本已通过url接口运行。 eg to resize an image I would call a script on one server either from the same or from one of the other servers as 例如,要调整图像的大小,我会在一个服务器上从同一服务器或其他服务器之一调用脚本

file_get_contents('http://mysite.com/resizeimg.php?img=file.jpg&x=320&y=480');

now, this works but we are upgrading to a new server structure where the code can be on the same machine. 现在,它可以工作,但是我们正在升级到新的服务器结构,其中代码可以在同一台计算机上。 So instead of all these wrapper functions I could just include and call a function. 因此,除了所有这些包装函数之外,我还可以包括并调用一个函数。 My question is: is it worth the overhead of rewriting the code to do this? 我的问题是:这样做值得重写代码吗?

I do care about speed, but don't worry about security -- I already I have a password system and certain scripts only accept from certain ips. 我确实关心速度,但是不用担心安全性-我已经有一个密码系统,并且某些脚本只接受某些ips。 I also care about the overhead of rewriting code but cleaner more understandable code is also important. 我还关心重写代码的开销,但更清晰,更易理解的代码也很重要。 What are the trade offs that people see here and ultimately is it worth it to rewrite it? 人们在这里看到哪些权衡取舍,最终值得重写吗?

EDIT: I think that I am going to rewrite it then to include the functions. 编辑:我想我要重写它,然后包括功能。 Does anyone know if it is possible to include between several servers of the same domain? 有谁知道是否可以在同一域的多台服务器之间进行添加? Like if there is a server farm where I have 2-3 servers can I have some basic functionality on one of them that the others can access but no one else could access from the outside? 就像有一个服务器场,其中有2-3台服务器,我是否可以在其中一台服务器上拥有一些基本功能,其他服务器可以访问这些功能,而其他人则不能从外部访问?

is it worth the overhead of rewriting the code to do this? 重写代码来执行此操作是否值得?

Most likely yes - a HTTP call will always be slower (and more memory intensive) than directly embedding the generating library. 很有可能是-HTTP调用总是比直接嵌入生成的库慢(并且占用更多内存)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM