appserver_Appserver-生产就绪的基于PHP的服务器-程序员宅基地

技术标签: python  java  linux  编程语言  大数据  

appserver

It has been just over a year and a half since the team at TechDivisionGmbH were interviewed here on Sitepoint about their paradigm changing PHP application server system called appserver.io. At the time of the interview, appserver was just breaking out as an alpha. Since then, a lot has happened and appserver is now GA as a production system, currently in version 1.0.6, with version 1.1.0 on the horizon.

自从TechDivisionGmbH的团队在Sitepoint接受采访以来,已经过去了一年半,他们的范式正在改变名为appserver.io的 PHP应用服务器系统。 在面试时,appserver只是一个alpha版本。 从那时起,发生了很多事情,appserver现已成为GA作为生产系统,目前的版本为1.0.6,而版本为1.1.0。

alt

You’re probably asking, “Why is appserver paradigm changing?”

您可能会问,“为什么应用服务器范式正在改变?”

The answer is, because it tackles the last frontier of PHP application development: high performance for large applications from a server resource optimization and collaboration perspective. This is the realm of PHP development which a good number of professional PHP developers have been calling for, like Manuel Lemos in his “PHP7 Features and Release Date” blog (see the section about a “Standalone Multi-threading Web Server”) and Fabien Potencier, father of Symfony, in his presentation “My Take on PHP”, where he notes he is also working on such an application server solution himself. Well, look no longer Fabien, we already have a really good solution with appsever.io.

答案是,因为它解决了PHP应用程序开发的最后一个领域:从服务器资源优化和协作的角度来看,大型应用程序具有高性能。 这是许多专业PHP开发人员一直在呼吁PHP开发领域,例如Manuel Lemos在他的“ PHP7功能和发行日期 ”博客中(请参阅有关“独立多线程Web服务器”的部分)和Fabien Symfony的父亲Potencier 在他的演讲“ My Take on PHP”中说 ,他自己也在从事这种应用服务器解决方案的研究。 好吧,看起来不再是Fabien,appsever.io已经为我们提供了一个非常好的解决方案。

Appserver Community Edition is licensed under the Open Source License 3.0. The TechDivsion team also offer a Professional Edition and an Enterprise Edition too.

Appserver社区版根据开放源代码许可3.0进行许可 。 TechDivsion团队还提供了专业版企业版

Appserver仍需要开发人员 (Appserver Still Needs the Developer)

Although the potential is within appserver to offer more performance and better collaboration between webservers in a web application environment, it cannot do it alone. It also requires new thinking from the PHP developer. It is this different perspective on solving problems, which we will dive into, with this 3 part series.

尽管在应用服务器内部有潜力在Web应用程序环境中提供更高的性能和更好的Web服务器之间的协作,但它不能单独做到这一点。 它还需要PHP开发人员的新思维。 这是解决问题的不同观点,我们将通过这三部分系列来探讨这一问题。

In this first part, we will go through very high level concepts that make appserver special and get you started with your first installation. In Part 2, we will go over the components appserver offers out-of-the-box in detail. And finally, in part 3, we will run with some use cases given to us through the example app provided in the installation package.

在第一部分中,我们将介绍非常高级的概念,这些概念使appserver变得特别,并让您开始进行首次安装。 在第2部分中,我们将详细讨论appserver提供的现成的组件。 最后,在第3部分中,我们将通过安装包中提供的示例应用程序提供一些用例。

The overall goal of this series will be to get your perspective opened to the new world of a possibly more performant application system with PHP and appserver and how it requires changes in development thinking and in some cases workflow.

本系列的总体目标是使您的视角向使用PHP和appserver的性能更高的应用程序系统的新世界开放,以及它如何要求更改开发思路,并在某些情况下更改工作流。

线程和线程 (Threads and Threading)

You might understand threading as the technology which allows modern computers to do multiple things at once. This is correct and where the term “multi-tasking” actually comes from.

您可能将线程理解为允许现代计算机一次执行多项操作的技术。 这是正确的,并且“ 多任务 ”一词实际上来自何处。

Threading or multitasking in the PHP world is actually quite rare. In the days when PHP was created, threading in computers wasn’t really much of a concern. PHP has stayed in line with its single-threaded architecture, also called “shared nothing” architecture, even to this day.

实际上,PHP世界中的线程或多任务处理非常少见。 在创建PHP的时代,计算机线程并不是什么大问题。 直到今天,PHP一直与单线程架构保持一致,这种架构也称为“无共享”架构。

What most people don’t realize, however, is that PHP is actually built to also support multitasking. This gem of functionality was basically unknown until Joe Watkins created pthreads, a powerful PHP extension which allows a developer to build threaded applications in PHP. It is this functionality, among other important features, which appserver implements to support the development of threaded applications.

但是,大多数人没有意识到,PHP实际上是为支持多任务而构建的。 在乔·沃特金斯(Joe Watkins)创建pthreads (一种功能强大的PHP扩展)之前 ,它基本上还未知。 appserver实施此功能以及其他重要功能来支持线程化应用程序的开发。

Still, you might be like me and wondering why this threading stuff makes any kind of difference for a PHP application. For that, we must actually take a look at a bird’s eye view of today’s webserver technology.

仍然,您可能像我一样,并且想知道为什么这种线程化的东西对PHP应用程序有什么不同。 为此,我们实际上必须全面了解当今的Web服务器技术。

标准PHP Web服务器方案 (The Standard PHP Web Server Scenario)

For us PHP developers, in the context of webservers, the thought of threading is far from our minds. That’s because the webservers and/or PHP process managers themselves are actually doing that work. You might be saying, “Great! That is one less problem for me to worry about” and you’d be absolutely correct in saying that. However, this handling of threading at the webserver / PHP process management level comes with a pretty big cost. Below is an animation of the current way PHP runs its processes with a webserver like Nginx.

对于我们PHP开发人员而言,在Web服务器的上下文中,线程的思想远非我们所想。 这是因为Web服务器和/或PHP流程管理器本身实际上是在做这项工作。 您可能会说:“太好了! 这是我担心的少一个问题”,您这样说绝对是正确的。 但是,这种在Web服务器/ PHP流程管理级别进行线程处理的成本很高。 以下是PHP在类似Nginx的Web服务器上运行其进程的当前方式的动画。

alt

The threading is done by duplicating, building, and destroying the same things over and over again, for each request the server receives. You might be thinking, this doesn’t look so bad, right? To see the real cost, we actually have to dive in a bit deeper and get into the “build/destroy” part of the process.

通过针对服务器收到的每个请求,一遍又一遍地复制,构建和销毁相同的内容来完成线程。 您可能会想,这看起来还不错,对吧? 要查看实际成本,我们实际上必须更深入地研究过程的“构建/销毁”部分。

alt

This image shows what a normal, usually larger application supported by some MVC framework must do for every single call made to it. We can argue about the sequence of events. However, what is important to notice is, there is a lot of work being done only to be completely destroyed after the response is sent. As mentioned above, this is a lot of duplicated and wasted effort for the machine. This waste = lost performance!

此图显示了某些MVC框架支持的正常的,通常是较大的应用程序必须执行的每个操作。 我们可以争论事件的顺序。 但是,值得注意的是,有很多工作要做,只是在发送响应后完全销毁了。 如上所述,这是机器的许多重复和浪费的工作。 浪费=失去性能!

Now let’s look at an appserver scenario from that bird’s eye view.

现在让我们从鸟瞰的角度来看一个应用服务器场景。

Appserver方案 (The Appserver Scenario)

alt

As you can see, nothing all too different. However, with appserver, the webserver is written in PHP and is an integrated part of the app. Now you have one less worry and, if necessary, you have more control over what is happening within the webserver. Also due to the webserver being integrated, a common part of modern PHP frameworks that deals with the HTTP requests and responses is basically put into its proper place in the stack, within the webserver itself.

如您所见,没有什么太大不同。 但是,使用appserver时,Web服务器是用PHP编写的,并且是该应用程序的集成部分。 现在,您不必担心,如果需要,您可以更好地控制Web服务器中发生的事情。 同样由于Web服务器被集成,处理HTTP请求和响应的现代PHP框架的公共部分基本上被放置在Web服务器本身内部的堆栈中。

This alone would be a great improvement over the standard webserver, however, it gets even better. Let’s look at the next level down, as we did earlier.

仅此一项就比标准Web服务器有很大的改进,但是,它变得更好。 让我们像之前一样看下一层。

alt

Notice how certain parts of the programming are no longer destroyed. What is destroyed or not is now in the developer’s hands. It means the developer can, for instance, allow the bootstrapping process to stay “threaded” and never have to be rebuilt for each request. The bootstrapped app is always ready to go.

注意如何不再破坏程序的某些部分。 开发人员现在可以控制销毁与否。 例如,这意味着开发人员可以允许引导过程保持“线程化”,而不必为每个请求都重新构建。 自举应用程序随时可以使用。

思维差异 (A Difference in Thinking)

When the difference appserver makes went “click” in my mind, this is about how I felt (click to view).

当appserver在我心中产生“点击”的不同时,这就是我的感受(点击查看)。

Having fun? Oh yes! And the most important part of the movie is what God says after this scene.

正玩得开心? 哦,是的! 电影中最重要的部分是上帝在这个场景之后说的话。

Parting your soup is not a miracle, Bruce. It’s a magic trick. A single mom who’s working two jobs and still finds time to take her kid to soccer practice, that’s a miracle. A teenager who says “no” to drugs and “yes” to an education, that’s a miracle. People want me to do everything for them. But what they don’t realize is they have the power. You want to see a miracle, son? Be the miracle.

分开汤不是奇迹,布鲁斯。 这是一个魔术。 一个单身母亲正在工作两个工作,但仍然有时间带她的孩子去足球练习,这是一个奇迹。 一个对毒品说“不”,对教育说“是”的少年,这是一个奇迹。 人们希望我为他们做一切。 但是他们没有意识到的是他们拥有力量。 你想看到奇迹吗,儿子? 成为奇迹。

Ok, maybe that is a bit melodramatic, but for sure, the “miracle” or the ability to make parts of your program basically persist within the server itself is a powerful tool to add performance to your applications. It allows you, as the PHP developer, to think differently about how an application can work better and faster. Though, as the rule goes…

好的,也许这有点戏剧化,但是可以肯定的是,“奇迹”或使程序的某些部分基本上能够在服务器本身中持久存在的能力是增强应用程序性能的强大工具。 作为PHP开发人员,它使您可以不同地思考应用程序如何更好,更快地工作。 不过,按规则行事……

With great power comes great responsibility.

拥有权利的同时也被赋予了重大的责任。

In other words, although you may have new powers at hand with appserver, you must also understand the meaning of those powers, how to use it and also the possible bad side-effects that can happen, when you aren’t careful. We’ll get into these things in more detail in the later parts of the series.

换句话说,尽管您可能拥有appserver的新功能,但您还必须了解这些功能的含义,使用方法以及不小心时可能发生的不良影响。 在本系列的后续部分中,我们将更详细地介绍这些内容。

For now, let’s get you up and running with an appserver instance.

现在,让我们启动并运行一个appserver实例。

安装与入门 (Installation and Getting Started)

Appserver comes ready to install for a good number of operating systems. A recommended approach to local development is to use a Vagrant VM built with Virtualbox. Or you could run with Bruno’s quick tip to build his homestead box. We will be installing the Debian Wheezy version of appserver and you will actually only need the running OS.

Appserver已准备就绪,可以安装许多操作系统 。 建议进行本地开发的方法是使用由Virtualbox构建Vagrant VM 。 或者,您可以利用Bruno的快速提示来构建他的宅基地盒子 。 我们将安装Debian Wheezy版本的appserver,实际上您只需要运行的OS。

After you have installed the VM and it is running, SSH into it and carry out these commands as the super-user.

在安装了VM并使其运行之后,将SSH插入其中并以超级用户身份执行这些命令。

echo "deb http://deb.appserver.io/ wheezy main" > /etc/apt/sources.list.d/appserver.list
wget http://deb.appserver.io/appserver.gpg -O - | apt-key add -
apt-get update
apt-get install appserver-dist

The installation process is just as simple with the other OSes too.

其他操作系统的安装过程也同样简单。

No matter which method you used to install appserver, you should be up and running with appserver. The installation routine automatically starts the appserver process after installation is complete. To check this quickly, enter the following.

无论您使用哪种方法安装appserver,都应在appserver上启动并运行。 安装例程在安装完成后自动启动appserver进程。 要快速检查,请输入以下内容。

service appserver status

You should see a running appserver.

您应该看到一个正在运行的应用服务器。

[ ok ] appserver is running.

A small note: If you reboot your VM, appserver will not run automatically. If you’d like to have it running at reboot, you need to set up the service to start at boot time. With Debian, you can carry out this command.

注意:如果重新启动VM,则appserver将不会自动运行。 如果您希望它在重新启动时运行,则需要将服务设置为在启动时启动。 使用Debian,您可以执行此命令。

update-rc.d appserver defaults

If you want appserver to actually serve up your web applications in general, you can also change appserver’s listening port to 80. To do this, you now need to make a simple change to the core configuration file in appserver. Go to /opt/appserver/etc/appserver and you will find a file called appserver.xml. This is the core configuration file for the webserver, much like Apache’s httpd.conf or Nginx’s nginx.conf files.

如果您希望appserver通常实际提供您的Web应用程序,还可以将appserver的监听端口更改为80 。 为此,您现在需要对appserver中的核心配置文件进行简单的更改。 转到/ opt / appserver / etc / appserver,您将找到一个名为appserver.xml的文件。 这是Web服务器的核心配置文件,非常类似于Apache的httpd.conf或Nginx的nginx.conf文件。

Open it up in your favorite editor and find these lines.

在您喜欢的编辑器中将其打开,然后找到这些行。

<server
            name="http"
            ....
            <param name="admin" type="string">[email protected]</param>
            <param name="transport" type="string">tcp</param>
            <param name="address" type="string">0.0.0.0</param>
            <param name="port" type="integer">9080</param>

If you are just experimenting, it would be best to leave the port as is. This way, you can play with appserver next to any other PHP projects.

如果您只是进行试验,最好将端口保持原样。 这样,您可以在任何其他PHP项目旁边使用appserver进行游戏。

There is a lot more you can do with the webserver and this configuration file. We’ll be going over some of the possibilities in the later posts.

您可以使用Web服务器和此配置文件做更多的事情。 我们将在以后的文章中讨论一些可能性。

If you did make any changes to the configuration file, you’ll need to restart appserver in order for the changes to take effect.

如果您确实对配置文件进行了更改,则需要重新启动appserver才能使更改生效。

service appserver restart

If all went well, you should be able to enter your VM’s IP address with :9080/example, like http://10.10.10.10:9080/example, and you should see the starting page of the example app already installed in appserver.

如果一切顺利,您应该可以使用:9080/example输入虚拟机的IP地址,例如http://10.10.10.10:9080/example ,并且应该看到已安装在appserver中的示例应用程序的起始页面。

alt

That’s it! You now have a running appserver. In the next part of the series, we will dig into the features of appserver and see what it offers out of the box. Stay tuned for more!

而已! 您现在拥有一个正在运行的应用服务器。 在本系列的下一部分中,我们将深入研究appserver的功能,并立即查看其提供的功能。 敬请期待更多!

翻译自: https://www.sitepoint.com/appserver-a-production-ready-php-based-server/

appserver

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/culi3182/article/details/108374237

智能推荐

React学习记录-程序员宅基地

文章浏览阅读936次,点赞22次,收藏26次。React核心基础

Linux查磁盘大小命令,linux系统查看磁盘空间的命令是什么-程序员宅基地

文章浏览阅读2k次。linux系统查看磁盘空间的命令是【df -hl】,该命令可以查看磁盘剩余空间大小。如果要查看每个根路径的分区大小,可以使用【df -h】命令。df命令以磁盘分区为单位查看文件系统。本文操作环境:red hat enterprise linux 6.1系统、thinkpad t480电脑。(学习视频分享:linux视频教程)Linux 查看磁盘空间可以使用 df 和 du 命令。df命令df 以磁..._df -hl

Office & delphi_range[char(96 + acolumn) + inttostr(65536)].end[xl-程序员宅基地

文章浏览阅读923次。uses ComObj;var ExcelApp: OleVariant;implementationprocedure TForm1.Button1Click(Sender: TObject);const // SheetType xlChart = -4109; xlWorksheet = -4167; // WBATemplate xlWBATWorksheet = -4167_range[char(96 + acolumn) + inttostr(65536)].end[xlup]

若依 quartz 定时任务中 service mapper无法注入解决办法_ruoyi-quartz无法引入ruoyi-admin的service-程序员宅基地

文章浏览阅读2.3k次。上图为任务代码,在任务具体执行的方法中使用,一定要写在方法内使用SpringContextUtil.getBean()方法实例化Spring service类下边是ruoyi-quartz模块中util/SpringContextUtil.java(已改写)import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.s..._ruoyi-quartz无法引入ruoyi-admin的service

CentOS7配置yum源-程序员宅基地

文章浏览阅读2w次,点赞10次,收藏77次。yum,全称“Yellow dog Updater, Modified”,是一个专门为了解决包的依赖关系而存在的软件包管理器。可以这么说,yum 是改进型的 RPM 软件管理器,它很好的解决了 RPM 所面临的软件包依赖问题。yum 在服务器端存有所有的 RPM 包,并将各个包之间的依赖关系记录在文件中,当管理员使用 yum 安装 RPM 包时,yum 会先从服务器端下载包的依赖性文件,通过分析此文件从服务器端一次性下载所有相关的 RPM 包并进行安装。_centos7配置yum源

智能科学毕设分享(算法) 基于深度学习的抽烟行为检测算法实现(源码分享)-程序员宅基地

文章浏览阅读828次,点赞21次,收藏8次。今天学长向大家分享一个毕业设计项目毕业设计 基于深度学习的抽烟行为检测算法实现(源码分享)毕业设计 深度学习的抽烟行为检测算法实现通过目前应用比较广泛的 Web 开发平台,将模型训练完成的算法模型部署,部署于 Web 平台。并且利用目前流行的前后端技术在该平台进行整合实现运营车辆驾驶员吸烟行为检测系统,方便用户使用。本系统是一种运营车辆驾驶员吸烟行为检测系统,为了降低误检率,对驾驶员视频中的吸烟烟雾和香烟目标分别进行检测,若同时检测到则判定该驾驶员存在吸烟行为。进行流程化处理,以满足用户的需要。

随便推点

STM32单片机示例:多个定时器同步触发启动_stm32 定时器同步-程序员宅基地

文章浏览阅读3.7k次,点赞3次,收藏14次。多个定时器同步触发启动是一种比较实用的功能,这里将对此做个示例说明。_stm32 定时器同步

android launcher分析和修改10,Android Launcher分析和修改9——Launcher启动APP流程(转载)...-程序员宅基地

文章浏览阅读348次。出处 : http://www.cnblogs.com/mythou/p/3187881.html本来想分析AppsCustomizePagedView类,不过今天突然接到一个临时任务。客户反馈说机器界面的图标很难点击启动程序,经常点击了没有反应,Boss说要优先解决这问题。没办法,只能看看是怎么回事。今天分析一下Launcher启动APP的过程。从用户点击到程序启动的流程,下面针对WorkSpa..._回调bubbletextview

Ubuntu 12 最快的两个源 个人感觉 163与cn99最快 ubuntu安装源下包过慢_un.12.cc-程序员宅基地

文章浏览阅读6.2k次。Ubuntu 12 最快的两个源 个人感觉 163与cn99最快 ubuntu下包过慢 1、首先备份Ubuntu 12.04源列表 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup (备份下当前的源列表,有备无患嘛) 2、修改更新源 sudo gedit /etc/apt/sources.list (打开Ubuntu 12_un.12.cc

vue动态路由(权限设置)_vue动态路由权限-程序员宅基地

文章浏览阅读5.8k次,点赞6次,收藏86次。1.思路(1)动态添加路由肯定用的是addRouter,在哪用?(2)vuex当中获取到菜单,怎样展示到界面2.不管其他先试一下addRouter找到router/index.js文件,内容如下,这是我自己先配置的登录路由现在先不管请求到的菜单是什么样,先写一个固定的菜单通过addRouter添加添加以前注意:addRoutes()添加的是数组在export defult router的上一行图中17行写下以下代码var addRoute=[ { path:"/", name:"_vue动态路由权限

JSTL 之变量赋值标签-程序员宅基地

文章浏览阅读8.9k次。 关键词: JSTL 之变量赋值标签 /* * Author Yachun Miao * Created 11-Dec-06 */关于JSP核心库的set标签赋值变量,有两种方式: 1.日期" />2. 有种需求要把ApplicationResources_zh_CN.prope

VGA带音频转HDMI转换芯片|VGA转HDMI 转换器方案|VGA转HDMI1.4转换器芯片介绍_vga转hdmi带音频转换器,转接头拆解-程序员宅基地

文章浏览阅读3.1k次,点赞3次,收藏2次。1.1ZY5621概述ZY5621是VGA音频到HDMI转换器芯片,它符合HDMI1.4 DV1.0规范。ZY5621也是一款先进的高速转换器,集成了MCU和VGA EDID芯片。它还包含VGA输入指示和仅音频到HDMI功能。进一步降低系统制造成本,简化系统板上的布线。ZY5621方案设计简单,且可以完美还原输入端口的信号,此方案设计广泛应用于投影仪、教育多媒体、视频会议、视频展台、工业级主板显示、手持便携设备、转换盒、转换线材等产品设计上面。1.2 ZY5621 特性内置MCU嵌入式VGA_vga转hdmi带音频转换器,转接头拆解

推荐文章

热门文章

相关标签