分布式计算 要不要把写日志独立成一个Server Remote Procedure Call Protocol

w

https://en.wikipedia.org/wiki/Remote_procedure_call

In distributed computing a remote procedure call (RPC) is when a computer program causes a procedure (subroutine) to execute in another address space (commonly on another computer on a shared network), which is coded as if it were a normal (local) procedure call, without the programmer explicitly coding the details for the remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote.[1] This is a form of client–server interaction (caller is client, executer is server), typically implemented via a request–response message-passing system. The object-oriented programming analog is remote method invocation (RMI). The RPC model implies a level of location transparency, namely that calling procedures is largely the same whether it is local or remote, but usually they are not identical, so local calls can be distinguished from remote calls. Remote calls are usually orders of magnitude slower and less reliable than local calls, so distinguishing them is important.

RPCs are a form of inter-process communication (IPC), in that different processes have different address spaces: if on the same host machine, they have distinct virtual address spaces, even though the physical address space is the same; while if they are on different hosts, the physical address space is different. Many different (often incompatible) technologies have been used to implement the concept.

History and origins[edit]

Response–request protocols date to early distributed computing in the late 1960s, theoretical proposals of remote procedure calls as the model of network operations date to the 1970s, and practical implementations date to the early 1980s. In the 1990s, with the popularity of object-oriented programming, the alternative model of remote method invocation (RMI) was widely implemented, such as in Common Object Request Broker Architecture (CORBA, 1991) and Java remote method invocation. RMIs in turn fell in popularity with the rise of the internet, particularly in the 2000s.

Remote procedure calls used in modern operating systems trace their roots back to the RC 4000 multiprogramming system,[2] which used a request-response communication protocol for process synchronization.[3] The idea of treating network operations as remote procedure calls goes back at least to the 1970s in early ARPANET documents.[4] In 1978, Per Brinch Hansen proposed Distributed Processes, a language for distributed computing based on "external requests" consisting of procedure calls between processes.[5]

Bruce Jay Nelson is generally credited with coining the term "remote procedure call" (1981),[6] and the first practical implementation was by Andrew Birrel and Bruce Nelson, called Lupine, in the Cedar environment at Xerox PARC.[7][8][9] Lupine automatically generated stubs, providing type-safe bindings, and used an efficient protocol for communication.[8] One of the first business uses of RPC was by Xerox under the name "Courier" in 1981. The first popular implementation of RPC on Unix was Sun‘s RPC (now called ONC RPC), used as the basis for Network File System.

Message passing[edit]

RPC is a kind of request–response protocol. An RPC is initiated by the client, which sends a request message to a known remote server to execute a specified procedure with supplied parameters. The remote server sends a response to the client, and the application continues its process. While the server is processing the call, the client is blocked (it waits until the server has finished processing before resuming execution), unless the client sends an asynchronous request to the server, such as an XHTTP call. There are many variations and subtleties in various implementations, resulting in a variety of different (incompatible) RPC protocols.

An important difference between remote procedure calls and local calls is that remote calls can fail because of unpredictable network problems. Also, callers generally must deal with such failures without knowing whether the remote procedure was actually invoked. Idempotent procedures (those that have no additional effects if called more than once) are easily handled, but enough difficulties remain that code to call remote procedures is often confined to carefully written low-level subsystems.

Sequence of events[edit]

  1. The client calls the client stub. The call is a local procedure call, with parameters pushed on to the stack in the normal way.
  2. The client stub packs the parameters into a message and makes a system call to send the message. Packing the parameters is called marshalling.
  3. The client‘s local operating system sends the message from the client machine to the server machine.
  4. The local operating system on the server machine passes the incoming packets to the server stub.
  5. The server stub unpacks the parameters from the message. Unpacking the parameters is called unmarshalling.
  6. Finally, the server stub calls the server procedure. The reply traces the same steps in the reverse direction.

Standard contact mechanisms[edit]

To let different clients access servers, a number of standardized RPC systems have been created. Most of these use an interface description language (IDL) to let various platforms call the RPC. The IDL files can then be used to generate code to interface between the client and servers.

https://zh.wikipedia.org/wiki/远程过程调用

远程过程调用(英语:Remote Procedure Call,缩写为 RPC)是一个计算机通信协议。该协议允许运行于一台计算机的程序调用另一台计算机的子程序,而程序员无需额外地为这个交互作用编程。

信息传递

远程过程调用是一个分布式计算客户端-服务器(Client/Server)的例子,它简单而又广受欢迎。远程过程调用总是由客户端服务器发出一个执行若干过程请求,并用客户端提供的参数。执行结果将返回给客户端。

标准化的沟通机制

为了允许不同的客户端均能访问服务器,许多标准化的 RPC 系统应运而生了。其中大部分采用接口描述语言(Interface Description Language,IDL),方便跨平台的远程过程调用。

要不要把写日志独立成一个Server,需考虑吞吐量,可靠性和负载。在非极高并发的情况下,本地磁盘写比RPC请求可靠性要高(失败率更低),而你丢给LogServer,它最终也还是要保存成文件的。吞吐量则是,本地磁盘的写入速度会不会跟不上数据的产生速度。负载则充分考虑机器的负载能力,例如有些服务器CPU占用很高,但是磁盘IO却很闲,这时写本地文件可充分利用闲置的IO资源。又或者某些服务器本身IO就很繁忙,但网络很闲,就可以考虑把数据通过网络丢给另外的服务去处理更好。

简单来说,就"写日志"本身来说,是一个简单需求,要是能用本地文件解决,就没必要再搞一个Client-Server的模式,通过RPC访问。

分布式架构需要通盘考虑。

时间: 2024-11-07 01:06:37

分布式计算 要不要把写日志独立成一个Server Remote Procedure Call Protocol的相关文章

HAproxy的负载均衡+日志独立+动静分离+读写分离的配置

主机环境   redhat6.5 64位 实验环境   服务端1 ip 172.25.29.2            服务端2 ip 172.25.29.3             管理端1 ip 172.25.29.1  防火墙状态:关闭 1.Haproxy的负载均衡及测试 A)负载均衡的配置 [[email protected] ~]# yum install haproxy -y            #安装haproxy [[email protected] ~]# vim /etc/h

利用TraceSource写日志

利用TraceSource写日志 从微软推出第一个版本的.NET Framework的时候,就在“System.Diagnostics”命名空间中提供了Debug和Trace两个类帮助我们完成针对调试和跟踪信息的日志记录.在.NET Framework 2.0中,微软引入了TraceSource并对跟踪日志系统进行了优化,优化后的跟踪日志系统在.NET Core中又经过了相应的简化..NET Core的日志模型借助TraceSourceLoggerProvider实现对TraceSource的整

NodeJS写日志_Log4js使用详解

今天和大家分享一下NodeJS中写日志的一个常用第三方包:Log4js. 跟随主流Blog特色,先简单介绍下Log4js的基本信息.介绍Log4js之前,需要先说一下Log4***,Log4***是由Apache提供的多平台下多语言下日志书写扩展包,目的很简单就是使日志书写更加方便简洁,同时对不同的业务日志能够进行灵活的分文件记录,同时也包含着详细的等级配置,为之后分级输出,检索,及程序自动解析提供更加便捷的支持(一家之言,非官方描述,领会精神).Log4***有很多语言的实现,比如Log4cp

C#多线程写日志

由于程序是3层架构的,所有多线程记录日志成了比较棘手的问题,以前还真就没有在意过写日志的问题,认为不过是写文件罢了~~!如今发现原来要实现文件共享,并且能够使多线程同时操作日志还不能相互冲突,真的很麻烦.当然要实现它我首先想到的是在网上搜,结果可能是我搜的不得其法,没发现结果,多数都是用lock,mutx等线程锁或互斥的方式写日志,偶想这样和单线程有啥区别吗?还是没能起到多线程应该有的效率! 后来问朋友,发现个log4net的东西,不过此物依然用到了线程互斥,看了源码发现的! 网络不行,朋友不知

Spring使用SLF4J代替Commons Logging写日志

项目的日志更换成slf4j和logback后,发现项目无法启动.错误提示java.lang.ClassNotFoundException: org.apache.commons.logging.Log,如图所示.原因是Spring默认使用commons logging写日志,需要桥接工具把日志输入重定向到slf4j.在项目中添加commons logging到slf4j的桥接器jcl-over-slf4j即可解决该问题. <dependency> <groupId>org.slf4

python(13)---发邮件、写日志、操作redis数据库

一.写邮件 import yagmail user = '[email protected]' password = 'rtcxbuejmqrdgjcd' #不是qq密码,是邮件授权码 在qq邮箱,设置--账户--开启POP3/SMTP服务,获得授权码 m=yagmail.SMTP(host='smtp.qq.com',user=user,password=password) #host-- 163邮箱用 tp.163.com m.send(to=['[email protected]','xx

C# 超高速高性能写日志 代码开源

1.需求 需求很简单,就是在C#开发中高速写日志.比如在高并发,高流量的地方需要写日志.我们知道程序在操作磁盘时是比较耗时的,所以我们把日志写到磁盘上会有一定的时间耗在上面,这些并不是我们想看到的. 2.解决方案 2.1.简单原理说明 使用列队先缓存到内存,然后我们一直有个线程再从列队中写到磁盘上,这样就可以高速高性能的写日志了.因为速度慢的地方我们分离出来了,也就是说程序在把日志扔给列队后,程序的日志部分就算完成了,后面操作磁盘耗时的部分程序是不需要关心的,由另一个线程操作. 俗话说,鱼和熊掌

python 统计时间,写日志

python 统计时间使用time模块,写日志使用logging模块,这两个都是标准模板. 测试socket使用socket模块 # 统计时间 ---------------------- import time start = time.time() end = time.time() stamp = end - start print "耗时", stamp # 日志 ----------------------- import loggingimport datetime cur

轻轻松松教你写日志-超级简单

最近在做一个项目,涉及到很多的服务,一步步调试相当麻烦,要在自己电脑上发布很多服务,又要全部开启.很费时间,出现问题,怎么解决最快呢?直接写日志,一步定位哪里出了错. Log4Net库是一个帮助程序员将日志信息输出到各种目标(控制台.文件 数据库等)的工具. Log4Net,相信哪个程序员都用过,但是可能是人家配置好了自己拿过来直接用,所以让自己写还是有点困难,听起来很高大上的样子,其实真的很简单.以前听别人讲,迷迷糊糊,知道那么回事,就是个写日志的.但是真正会用还是在项目中自己真正的实践. 下