Ethereum nodejsrpc
1, in the form of codcodcodcodcodes:
1
2
5
6
7
8
/ > ..........
............................................................................................................................................................................. face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face face 42
43
44
45
46
47
48
49
50
51
51
57
57
57
57
58
58
58
5959
6060
61
61
61
62
62
6363
64
83
84
85
86
87
88
89
90
91
com.yun.test;< Cannot initialise Evolution's mail component.br/>Import java.rmi.RemoteException;< %s at %s Cannot initialise Evolution's mail component.br/>import org.apache.axis.client.Service;< error-console-action %s (%s) %s at %s %s at %s Cannot initialise Evolution's mail component. Cannot initialise Evolution's mail component.br/>Import java.net.MalformedURLException;< Import javax.xml.rpc.ServiceException;< Import javax.xml.soap.Name;< Import javax.xml.soap.SOAPException;
First, the characteristics of nodejs
let's take a look at the introction on the official website of nodejs:
node.jsis a platform build on Chrome's javascriptruntime for easily building fast, scalable network applications.node.jsuses an event driven, non blocking I / O model that makes it lightweight and efficient, Perfect for data intensive real-time applications that run across distributed devices.
its features are as follows:
1. It is a JavaScript running environment
2. It relies on chrome V8 engine for code interpretation
3. Event driven
4. Non blocking I / O
5. Lightweight, scalable, suitable for real-time data interaction applications
6, Single thread
2. The solution to system bottleneck brought by nodejs
its emergence can indeed provide us with new ideas and solutions to solve the system bottleneck in reality. Let's see what problems it can solve
1. Concurrent connection
for example, imagine a scenario where we queue up in a bank to handle business. Let's take a look at the following two models
(1) system thread model:
the problem of this model is obvious. There is only one thread on the server side, and only one concurrent request (user) can be processed when it arrives. The rest have to wait first, which is blocking. The requests that are enjoying the service block the subsequent requests
(2) multithreading and thread pool model:
this model has made progress compared with the previous one. It adjusts the number of server threads to improve the reception and response of concurrent requests, but when the concurrency is high, requests still need to wait, which has a more serious problem. From the code level, let's look at the process of communication between the client and the server:
every time a connection is established between the server and the client, a set of supporting resources should be allocated for the connection, which is mainly reflected in the system memory resources. Taking PHP as an example, maintaining a connection may require 20m of memory. That's why when the amount of concurrency is large, more servers need to be opened
so how does nodejs solve this problem? Let's take a look at another model. Imagine that we order at a fast food restaurant
(3) asynchronous and event driven model
we also need to initiate requests and wait for the server to respond; But different from the bank example, this time we get a number after ordering. When we get the number, we often wait in the position, and the requests behind us will continue to be processed. We also get a number and wait. The receptionist can always process it
when the food number is ready, we will call the number, and we will get our own food for subsequent processing (eating). This action of calling numbers is called callback in nodejs. It can continue to perform the following logic (eating) after the event (cooking, I / O) processing is completed. This reflects the remarkable characteristics of nodejs. The asynchronous mechanism and event driven do not block the connection of new users (ordering), and it does not need to maintain the connection between users who have ordered and cooks
based on this mechanism, in theory, nodejs can respond to user requests one after another, so nodejs can support higher concurrency than Java and PHP programs. Although maintaining the event queue also costs money, and because nodejs is a single thread, the longer the event queue is, the longer the response time will be, and the concurrency will still be insufficient
to summarize how nodejs solves the problem of concurrent connection: change the way of connecting to the server, each connection emits an event running in the nodejs engine process and puts it into the event queue, instead of generating a new OS thread for each connection (and allocating some supporting memory for it)
I / O blocking another problem that nodejs solves is I / O blocking. Let's take a look at a business scenario where data needs to be pulled from multiple data sources and then processed(1) serial acquisition of data, which is our general solution, take PHP as an example
if the operation of obtaining profile and timeline needs 1s respectively, then serial acquisition needs 2S
(2) nodejs non blocking I / O, transmitting / listening events to control the execution process
nodejs will create a thread to execute when encountering I / O events, and then the main thread will continue to execute. Therefore, taking the profile action to trigger an I / O event will immediately execute the action of taking the timeline, and the two actions will be executed in parallel, if 1s is required for each, So the total time is 1s. After their I / O operations are completed, they send an event, profile and timeline. After receiving the event, the event agent continues to execute the following logic. This is the characteristic of nodejs non blocking I / O
to sum up: Java and PHP can also implement parallel requests (sub threads), but nodejs will do it naturally through callback function and asynchronous mechanism
Advantages and disadvantages of nodejs: 1. High concurrency (the most important advantage)2. Suitable for I / O intensive applications
disadvantages: 1. Not suitable for CPU intensive applications; 2; The main challenges that CPU intensive applications bring to node are: e to JavaScript single thread, if there are long-running calculations (such as large loops), the CPU time slice will not be released and subsequent I / O will not be initiated
solution: decompose the large computing task into several small tasks, so that the computing can be released in time, without blocking the initiation of I / O call
2. Only support single core CPU, can not make full use of CPU
3. Low reliability, once a part of the code crashes, the whole system will crash
reasons: single process, single thread
solutions: (1) nnigx reverse proxy, load balancing, open multiple processes, bind multiple ports
(2) open multiple processes to listen to the same port and use the cluster mole
The quality of open source component library is uneven, the update speed is fast, and the downward incompatibility is poor.
5. It is inconvenient to debug, and there is no stack track for errors.
4. Suitable for nodejs scenario
1. Restful API
this is the most ideal application scenario of nodejs, which can handle tens of thousands of connections without too much logic. It only needs to request API and organize data to return. It essentially just looks up some values from a database and makes them into a response. Because the response is a small amount of text and the inbound request is also a small amount of text, the traffic is not high, and a machine can even handle the API requirements of the busiest companies
2. Unified UI layer of web application
the current MVC architecture, in a sense, web development has two UI layers, one is in the browser, the other is in the server, responsible for generating and splicing pages
we don't discuss whether this architecture is good or bad, but there is another practice, service-oriented architecture, which can better separate the front and back-end dependencies. If all the key business logic are encapsulated as rest calls, it means that the upper layer only needs to consider how to use these rest interfaces to build specific applications. Those back-end programmers don't worry about how the specific data is transferred from one page to another, and they don't care whether the user data update is obtained asynchronously through Ajax or through refreshing the page
3. Applications with a large number of Ajax requests
for example, personalized applications, each user sees a different page, and the cache fails. Ajax requests need to be initiated when the page is loaded, and nodejs can respond to a large number of concurrent requests. All in all, nodejs is suitable for high concurrency, I / O intensive, and a small amount of business logic scenarios
Advantages and disadvantages ofPython
advantages
simplicity -- Python is a language representing the idea of simplicity. Reading a good Python program is like reading English, although the English requirements are very strict! This pseudo code nature of Python is one of its greatest advantages. It allows you to focus on solving problems instead of understanding the language itself
easy to learn - as you will see, Python is extremely easy to learn. As mentioned earlier, python has an extremely simple syntax
free and open source -- Python is one of floss (free / open source software). In short, you are free to publish copies of the software, read its source code, make changes to it, and use part of it in new free software. Floss is based on the concept of a community sharing knowledge. That's one of the reasons why Python is so good - it's created and constantly improved by a group of people who want to see a better python
high level language - when you write a program in Python, you don't need to consider the underlying details such as how to manage the memory used by your program
portability - e to its open source nature, python has been ported to many platforms (modified to work on different platforms). If you are careful not to use system dependent features, all your Python programs can run on any of the following platforms without modification. These platforms include Linux, windows, FreeBSD, Macintosh, Solaris, OS / 2, Amiga, Aros, as / 400, beos, OS / 390, Z / OS, Palm OS, QNX, VMS, psion, ACOM RISC OS, VxWorks, PlayStation, sharp Zaurus, Windows CE, and even PocketPC, Symbian and Google's Android platform based on Linux
interpretability -- this point needs some explanation. A program written in a compiler language such as C or C + + can be converted from a source file (i.e. C or C + + language) to a language (binary code, i.e. 0 and 1) used by your computer. This process is accomplished through the compiler and different tags and options. When you run your program, the connection / loader software copies your program from the hard disk to memory and runs it. Programs written in Python do not need to be compiled into binary code. You can run the program directly from the source code. Inside the computer, the Python interpreter converts the source code into an intermediate form called bytecode, then translates it into the machine language used by the computer and runs it. In fact, because you no longer have to worry about how to compile programs, how to make sure that the connection loads the correct library, and so on, all of this makes it easier to use python. Because you only need to your Python program to another computer, it can work, which makes your Python program more portable
Object Oriented -- Python supports both process oriented programming and object-oriented programming. In process oriented languages, programs are built by processes or functions that are just reusable code. In the "Object-Oriented" language, the program is constructed by the combination of data and function. Compared with other major languages such as C + + and Java, python implements object-oriented programming in a very powerful and simple way
scalability - if you need a piece of your key code to run faster or you want some algorithms to be private, you can write some of your programs in C or C + +, and then use them in your Python programs
embeddable
