Yar-parallel RPC framework (ConcurrentRPCframework)

Source: Internet
Author: User
Tags php framework php website zip extension
Author: Laruence () address of this article: www.laruence.com201209152779.html record the source Yar (yetanotherRPCframework) I developed a PHP extension and RPC framework to solve a practical problem more than three months ago,

Author: Laruence () address of this article: http://www.laruence.com/2012/09/15/2779.html reprint please indicate the source of Yar (yet another RPC framework, the instructor asked me why are Ya headers, hehe, because such a good name) I developed a PHP extension and RPC framework to solve a practical problem more than three months ago,

  • Author: Laruence ()
  • Address: http://www.laruence.com/2012/09/15/2779.html
  • Reprinted please indicate the source

Yar (yet another RPC framework, the instructor asked me why all of them are Ya's headers, huh, because the name is good.) I tried to solve a practical problem more than three months ago, developed a PHP extension, the RPC framework, is different from the existing RPC framework (xml-rpc, soap). This is a lightweight framework that supports multiple packaging protocols (msgpack, json, php), and the most important feature is that it can be parallel ..

Consider the following scenarios:

Traditional Web applications, a process, and a request, are well handled. However, when a request is processed, it involves multiple data sources and there is no dependency between them.

It is also a traditional Web application. With the rapid growth of the business, the flow of developers will slowly enter a vicious circle, and only addition and subtraction are available for the amount of code. as the system becomes more complex, the system will change the overall situation. The new maintainer does not have that much time to grasp the original system. even with so much time, it is not easy to grasp the combination of the thinking of so many defenders in the past...

In the past, the system will become increasingly unavailable .... When a large application enters this vicious circle, only reconstruction is needed.

So can we decouple this system?

We have already done a lot of decoupling, Data, middleware, business, logic, and so on, and various layers. But how can we identify the Web application? MVC has already been done ....

Based on this, Yar may solve these two problems...

Yar is a very lightweight RPC framework. When implementing Yar, I pursue the ultimate lightweight architecture. It is very simple to use. For the Server side:

 handle();?>

Is it similar to how Soap is used? Yes. In this way, your API class can provide external services ..

Yar binds the document and interface to facilitate development. For the above example, if we use a simple GET request for this interface address, we will see the following information page:

In this way, we can mark the interface information in the annotations so that the document and interface can be together.

For the Client, simple serial calls are very simple:

 api("parameter);?>

In this way, if you have multiple services, you only need one client.

So what about the most exciting parallel call?

 

In this way, all requests will be sent once. As long as any request is completed, the callback function "callback" will be called immediately.

Here is another detail. Yar does not waste any time. After these requests are sent, Yar calls a callback, which is different from the callback returned by a common request, the $ callinfo parameter of this call is blank.

In this way, we can send the request first, and then call back for the first time to continue the work of our current process. After all the work is completed, we will hand over the Yar to get the response of the parallel RPC.

 

With this, we can process multiple data sources in a Web application in parallel, so that we can decouple these logics and deploy them separately...

Of course, Yar is still in the trial phase, so no package (Yar at PECL) has been released ), however, if you are interested, you can clone the code for trial now (although you have not officially put it into trial use, it has been verified ).

Yar: Yar at Github

PS. If you want to use Msgpack (an efficient binary packaging protocol) as the packaging protocol, you need to install the Msgpack extension (Msgpack) separately. This extension is also maintained at present, I will release it on PECL in the last few days.

Comments
  • 2012/09/15, pangbin writes: I learned. Will you go to Weibo campus to recruit me?
  • July 16, Chinese New Year's story-xlinblog.sinaapp.com» Yar-parallel RPC framework (Concurrent RPC framework) writes: [...] address: http://www.laruence.com/2012/09/15/2779.html [...]
  • , Yar-parallel RPC framework (Concurrent RPC framework) forest/coffee Chengdu professional php website production | forest/coffee Chengdu professional php website production writes: [...] snow? PHP source code analysis Posted in: php/Tagged: framework, parallel RPC framework Concurrent [...]
  • , Fnsoxt writes: This is awesome. Support. Enter 1.0 soon. Haha, I will definitely use it.
  • , Rango writes: there are more and more servers using PHP. Bird brother is supported. This is also a high-performance Server. https://github.com/matyhtf/php_swoole with extensions
  • , Wonderful things-reading xlinblog.sinaapp.com» Yaf and Phalcon, which is faster? Writes: [...] Yar-parallel RPC framework (Concurrent RPC framework) [...]
  • , Anonymous writes: Compile/usr/local/src/yar/yar_client.c: 473: 4: error: non-void function 'php _ yar_concurrent_client_callback' shocould return a value will report an error. I just want to change it to return 0.
  • , LBJ writes: Compile/usr/local/src/yar/yar_client.c: 473: 4: error: non-void function 'php _ yar_concurrent_client_callback' shocould return a value will report an error. I just want to change it to return 0.
  • , Snow migratory bird writes: @ LBJ thanks, fixed
  • , Erick writes: This is a good thing, niao brother. What about your sample? The server startup parameter will report that the client does not try catch. When Will documents be issued? Currently, yar and hprose are involved.
  • , Bee writes: I downloaded the yar package on pecl, but I don't know how to compile it into a dll. Can the blogger give it a dll?
  • , Pangee writes
  • , Writes: Find the dll file
  • , Enter writes: Bird brother PHP Fatal error: Uncaught exception 'ar _ Client_Protocol_Exception 'with message 'malformed protocol header, maybe not responsed/sent by a Yar rpc server/client? 'Is it swollen? serverhandle ();?> Clientapi ("parameter"); var_dump ($ result);?>
  • , About PHP compilation and execution separation | 5 iphp writes: [...] Yar-parallel RPC framework (Concurrent RPC framework) [...]
  • , Xuchanglong writes: laruence, I have been wondering what advantages does PRC and HTTP have in addition to calling between different languages? As far as I understand, yar PRC requires PHP to start the monitoring process, while HTTP uses nginx or other web services to monitor the processing capability of the process and is sometimes very strong, but at the same time, something similar to zookeeper needs to start the monitoring process at high concurrency
  • , Yar-parallel RPC framework (Concurrent RPC framework) | afternoon nap writes: [...] address: http://www.laruence.com/2012/09/15/2779.html [...]
  • , PHP & "Data" URL scheme | afternoon nap writes: [...] Yar-parallel RPC framework (Concurrent RPC framework) [...]
  • , Please manually release your resources (Please release resources manually) | afternoon nap writes: [...] Yar-parallel RPC framework (Concurrent RPC framework) [...]
  • , Yaf resources | afternoon nap writes: [...] Yar-parallel RPC framework (Concurrent RPC framework) [...]
  • , PHP Calling Scope | afternoon nap writes: [...] Yar-parallel RPC framework (Concurrent RPC framework) [...]
  • 2013/05/18, match these midi dresses with a large bag10 writes: Howdy! This is my first comment here so I just wanted to give a quick shout out and tell you I truly enjoy reading through your posts. can you recommend any other blogs/websites/forums that deal with the same subjects? Appreciate it!
  • , Learsu writes: laruence, yar Design Concept communication between PHP applications/It has the ability to concurrently call multiple remote services. Similar to Gearman, I don't know if I understand It.
  • , Yuting writes: The test script of laruence is a bit problematic. It is okay to modify the Api: api () method to something else, otherwise it will be considered as _ construct (); class API {/*** the doc info will be generated automatically into service info page. * @ params * @ return * // The api interface is called by default, which is equivalent to _ construct (); public function api ($ parameter, $ option = "foo ") {} protected function client_can_not_see () {}}$ service = new Yar_Server (new API (); $ service-> handle ();?>
  • , Jeryu writes: laruence. We can see that version 1.1.0 supports TCP/UNIX and persistent links. However, the github documentation is not updated. Could you give me a simple example to introduce the usage.
  • , Jia Chen writes: laruence, do you have time to come up with a set of source code manuals or materials?
  • , Chs writes: laruence, I just tried YAR. I have a question. When the client is calling, the program will be stuck in the loop Line... I don't know if my program is improperly written or is it true ?? In my initial understanding, the program will continue to execute in sequence until a request is automatically executed. Is this more efficient? Please enlighten me...
  • , New serialization class library MessagePack, faster and smaller than JSON | LAMP | he Yue's blog writes: [...] this MessagePack PHP extension is developed and maintained by Laruence, a legendary bird brother. In Yar of Bird brother, MessagePack is also used as one of the packaging protocols. [...]
  • 2013/10/06, ?writes: Who is the instructor. It looks amazing.
  • 2013/10/08, h3110c writes: Does laruence know whether there is something to call the rest api in parallel?
  • , Liangh writes
  • , Tree blog» Yar learning, and the application in the production environment (phpcms) writes: [...] First, I checked the article of laruence? Yar-parallel RPC framework )?, I have an understanding of the basic principles of Yar and made a simple request page. For details, see the blog of laruence. The next step is to transform the existing project. [...]
  • , Deeka writes: Yar has been integrated into ThinkPHP! Http://www.thinkphp1.cn/extend/529.html
  • , Chew ice writes: the second part of the code missing a colon
  • , Chew ice writes: Correct downstairs: Colon-> double quotation marks
  • , Munggruel writes: in windows, php5.4 assets yar dll extension encountered the same problem. How to Solve PHP Fatal error: Uncaught exception 'yar _ Client_Protocol_Exception 'with message 'malformed
  • 2014/08/08, Gao Hua writes: Can yar only use the http protocol? Is this too heavy? Can I use a light protocol?
  • 2014/09/08, disturbed stricken writes: of course like your web site but you have to take a look at the spelling on quite a few of your posts. A number of them are rife with spelling problems and I find it very troublesome to inform the reality then again I'll certainly come again.
  • , Zhou Zhichao writes: laruence, I reported an exception using your demo. The following malformed response header 'Warning: missing' is not clear about why. Please kindly advise
  • , HA entertainment writes: I use the environment is php 5.6.6 x86 thread security edition, in windows fuse and php_msgpack-0.5.5-ts-vc11-x86.zip extension, put php_yar.dll and php_msgpack.dll two files in ext extension directory, configured php. restart apache after the INI file, and then the two extensions cannot be found in the printed phpinfo information. I don't know where the problem is? When you test the yar php instance, the following error occurs: Fatal error: Class 'ar _ Server' not found.
Related posts:
  • Yaf-a PHP extension implementation framework
  • Yaf and Phalcon, which is faster?
  • Yaf-a php Framework Extension
  • PPT presented at the China PHP Technology Summit Forum (2011)
  • Yaf Resources
Copyright©2010 All Rights Reserved. this Feed is for personal use only. reposted or commercial applications that are not specified are prohibited. if the application is illegal, all legal consequences shall be borne by you. if you have any questions, you can send an email to my at laruence.com. (Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.