Decentralized RPC
Ethereum is a new and open blockchain platform, which allows anyone to build and use decentralized applications running through blockchain technology in the platform. Like bitcoin, Ethereum is neither controlled nor owned by anyone - it's an open source project created by many people around the world
Different from bitcoin protocol, Ethereum is very flexible and adaptable. It's very easy to create new applications on the Ethereum platform. Anyone can use the applications on the platform safely
Ethereum is a programmable blockchain. It does not give users a series of preset operations (such as bitcoin trading), but allows users to create complex operations according to their own wishes. In this way, it can be used as a platform for many types of decentralized blockchain applications, including but not limited to cryptocurrency
in a narrow sense, Ethereum refers to a series of protocols that define a decentralized application platform. The core of Ethereum is Ethereum virtual machine (EVM), which can encode any complex algorithm. In computer science terminology, Ethereum is "Turing complete.". Developers can use the existing JavaScript and python as the model of other friendly programming languages to create applications running on the Ethereum simulator
like other blockchains, Ethereum also has a peer-to-peer network protocol. Ethereum blockchain database is maintained and updated by many nodes connected to the network. Each network node runs the Ethereum simulator and executes the same instructions. Therefore, people sometimes call Ethereum "world computer"
this massive parallel operation throughout the Ethernet network is not to make the operation more efficient. In fact, this process makes computing on Ethereum slower and more expensive than on traditional computers. However, each Ethereum node runs Ethereum virtual machine in order to maintain the consistency of the whole blockchain. The consistency of decentralization makes Ethereum have high fault tolerance, zero downtime, and can keep the data stored on the blockchain unchanged and anti censorship
Ethereum platform has no characteristics and value. Like programming languages, it's up to entrepreneurs and developers to decide what to use. However, it is clear that some application types benefit more from the functions of Ethereum than others. Ethereum is especially suitable for those applications that automatically interact directly between points or promote group coordination activities across networks
for example, coordinate the application of point-to-point market, or the automation of complex financial contracts. Bitcoin enables indivials to exchange money without the help of financial institutions, banks or governments. The impact of Ethereum may be more profound
in theory, any complex financial activities or transactions can be automatically and reliably carried out on Ethereum with coding. In addition to financial applications, any application scenario with high requirements for trust, security and persistence, such as asset registration, voting, management and Internet of things, will be affected by Ethereum platform on a large scale
according to Xiao Wang, the concept of blockchain as a service (baas) is mainly proposed by Microsoft and IBM. To put it bluntly, it is actually a new type of cloud service, a cloud service combined with blockchain technology. For example, Microsoft's azure cloud computing platform and IBM's bluemix garage cloud platform all provide blockchain as a service baas
blockchain as a service (baas) is a space created by enterprises such as Microsoft and IBM from their own cloud service network to run a blockchain node. Compared with ordinary nodes and exchange nodes, the main purpose of baas nodes is to quickly establish the development environment they need, and provide a series of operation services based on blockchain, such as search query, transaction submission, data analysis, etc. these services can be centralized or decentralized to help developers verify their concepts and models faster. The service of baas node is reflected in: it is more instrumental and easy to create, deploy, run and monitor blockchain.
config layer
proxy layer
registry layer
cluster layer
monitor layer
protocol layer
exchange layer
transport layer
serialize Data serialization layer)
external configuration interface
with serviceconfig and referenceconfig as the center, you can directly create new configuration class, or generate configuration class through spring parsing configuration
javassist proxyfactory
JDK proxyfactory
transparent proxy of service interface, generate client stub and server skeleton of service
with serviceproxy as the center, The extension interface is proxyfactory
select
zookeeper
redis
multicast
Simple
support network-based cluster mode, have a wide range of peripheral open source procts, it is recommended to use bbo-2.3.3 or above (recommended)
depending on the stability of zookeeper
support client-side al write cluster mode, High performance
requires server time synchronization for checking heartbeat expired dirty data
decentralizes, does not need to install registry
depends on network topology and routing, cross machine room risk
dogfood, registry itself is a standard RPC service
without cluster support, Possible single point of failure
encapsulates the registration and discovery of service address
with service URL as the center, and the extension interface is registryfactory, registry, and registryservice
select
spring
jetty
log4j
automatically load all spring configurations in the meta-inf / spring directory
start an embedded jetty, When it is used to report status
when a large number of pages are accessed, the thread and memory of the server will be affected
the log4j configuration will be automatically configured. When a multi process is started, the log file will be automatically subdirectored according to the process
the user can not control the log4j configuration, which is inflexible
conditional routing
script routing
routing rules based on conditional expressions, The function is simple and easy to use
in some complex multi branch conditions, the rules are difficult to describe
the routing rules based on script engine are powerful
there is no running sandbox, and the script ability is too strong, which may become a backdoor
Random
roundrobin
leadactive
consistenthash
random, Setting random probability according to weight (recommended)
the probability of collision on a section is high, when retrying, the instantaneous pressure may be uneven
round robin, setting round robin ratio according to the weight after the Convention
there is a slow machine cumulative request problem, and in extreme cases, there may be avalanche
the minimum number of active calls, the same number of active random calls, Active number refers to the count difference before and after the call, so that slow machines receive less requests
weight is not supported. In capacity planning, pressure can not be directed to a machine to measure capacity through weight
consistency hash. Requests with the same parameters are always sent to the same provider. When a provider is hung up, the original requests to the provider are based on virtual nodes, It will not cause drastic changes if it is shared equally with other providers
uneven pressure distribution
failfast
failsafe
failback
forcing
broadcast
when failure occurs, it will switch automatically and try other servers again, It is usually used for read operation (recommended)
retrying will bring longer delay
quick failure. Only one call will be initiated, and an error will be reported immediately if the call fails. It is usually used for non idempotent write operation
If a machine is restarting, the call may fail
fail safe. When an exception occurs, it will be ignored directly, It is usually used to write audit log and other operations
call information loss
automatic recovery of failure, background recording of failure requests, and regular resend. It is usually used for message notification operations
unreliable, restart loss
call multiple servers in parallel, and return as long as one succeeds, It is usually used for the read operation with high real-time requirements
it needs to waste more service resources
broadcast and call all providers one by one, and any one will report an error. It is usually used to update the local state of the provider
the speed is slow, and any one will report an error
encapsulate the routing and load balancing of multiple providers, and bridge the registry center
with the invocker as the center, The extension interface is cluster, directory, router, loadbalance
cluster selection
router selection
routing rules
container
RPC call times and call time monitoring
statistics as the center, the extension interface is monitorfactory, monitor, Monitorservice
Dubbo protocol
RMI protocol
Hessian protocol
number of connections: single connection
connection mode: long connection
transmission protocol: TCP
transmission mode: NiO asynchronous transmission
serialization: Hessian binary serialization
scope of application: small incoming and outgoing parameter packets (less than 100k recommended), There are more consumers than providers, and a single consumer can't fill the providers. Try not to use BBO protocol to transfer large files or large strings
applicable scenario: general remote service method call
NiO is used to reuse single long connection, and thread pool is used to process requests concurrently, so as to rece handshake and increase concurrency efficiency, with good performance (recommended)
it is suitable for service call with small amount of data and large concurrency, As well as the case that the number of service consumer machines is much larger than that of service provider machines,
Dubbo default protocol is not suitable for transferring services with large amount of data, such as transferring files and videos, unless the amount of requests is very low
Dubbo default protocol uses a single long connection per service per provider per consumer, if the amount of data is large, Multiple connections can be used
in order to prevent being hung up by a large number of connections, the service provider can limit the number of large receiving connections to achieve self-protection of the service provider
in large file transmission, a single connection will become a bottleneck
summary
it can interoperate with native RMI, and the connection will fail occasionally based on TCP protocol, You need to rebuild the stub
parameters and return values, you need to implement the serializable interface
parameters and return values can't be customized to implement the list, map, number, date, calendar and other interfaces, you can only use the JDK's own implementation, because Hessian will do special processing, Attribute values in custom implementation classes will be lost
number of connections: multiple connections
connection method: short connection
transmission protocol: http
transmission method: synchronous transmission
serialization: Hessian binary serialization
scope of application: the number of incoming and outgoing parameter packets is large, the number of providers is more than that of consumers, and the pressure of providers is large, Transmissible file
applicable scenarios: page transfer, file transfer, or interoperation with native Hessian service
the provider exposes the service with Dubbo's Hessian protocol, and the consumer calls it directly with standard Hessian interface
or the provider exposes the service with standard Hessian, Consumers use Dubbo's Hessian protocol to call
Hessian based remote calling protocol
which can interoperate with native Hessian. Based on HTTP protocol
hessian.jar support is required, and HTTP short connection cost is large
Hessian protocol is used to integrate Hessian services. The underlying layer of Hessian uses HTTP communication and servlet to expose services, Dubbo default embedded jetty as a server
can interoperate with native Hessian services
summary
constraints
encapsulate RPC calls
with invocation, result as the center, extension interface as protocol, invoker, exporter
select
encapsulate request response mode, synchronous to asynchronous
with request, response as the center, The extended interface is exchange, exchangechannel, exchangeclient, exchangeserver
netty
Mina
grizzly
better performance (recommended)
one request to distribute two kinds of events, need to shield useless events
old NiO framework, stable
to send message queue is not timely, under high pressure, will appear fullgc
SUN NiO framework, When applied to GlassFish server,
thread pool is not extensible, and filter cannot intercept the next filter.
Abstract Mina and netty are the unified interfaces.
message is the center, and the extended interfaces are channel, transporter, client, server and codec.
select
Hessian
Dubbo
JSON
java
with better performance, Multilingual support (recommended)
the compatibility of different versions of Hessian is not good, which may conflict with the Hessian used by the application. Dubbo has embedded the source code of Hessian 3.2.1
by not transmitting the class information of POJO, the performance is better when a large number of POJOs are transmitted
when adding fields to parameter objects, it needs to declare an external file
plain text, which can be parsed across languages, By default, fastjson is used to resolve
poor performance
java native support
poor performance
reusable tools
the extension interfaces are serialization, objectinput, objectoutput, ThreadPool
select
business
RPC
remoting
Service
config
proxy
registry
cluster
monitor
protocol
exchange
transport
serialize
hierarchy
layer description
in the long-term struggle, we have summed up many ways to expand the bottom relational database:
1. Master slave, one master and many slaves, double write, temporary request through queue... These solutions actually do not solve the problem, write is still a single point, and the challenge for DBA is relatively large, we will not discuss it today
2. Through sharding middleware, common open source solutions include Cobar, tddl, Vites, kingshard, MYCAT, etc. the idea of these solutions is to intercept SQL requests, forward / broadcast requests to different MySQL instances through sharding key and certain rules, so as to achieve the effect of horizontal expansion. This solution basically solves the problem of single point writing, For the business, the overall throughput has also come up, which seems good. This solution is the solution for most business to meet the performance bottleneck, but there are also some disadvantages:
1) most middleware do not solve the problem of dynamic expansion, and mostly adopt static routing strategy. The expansion is generally in the state of manual X2, which requires higher requirements for DBA
2) to a certain extent, they all give up the transaction. This is because a statement may involve multiple database instances. It is difficult to implement distributed transaction, which we will introce in detail later
3) it is not transparent to business and needs to specify sharding key, which is a heavy mental burden
