What is session? What is a cookie? What is the difference between session and cookie? What scenarios apply to sessions? What scenarios apply to cookies?

This is the back-end small class of the monastery. Each article is shared from

[background introduction] [knowledge analysis] [common problems] [solutions] [coding practice] [extended thinking] [more discussion] [References]

Eight aspects of in-depth analysis of back-end knowledge / skills. This article shares:

[what is a session? What is a cookie? What is the difference between a session and a cookie? What scenario applies to a session? What scenario applies to a cookie?]

1. Background introduction

What is pressure measurement?

Stress testing is to test the performance of the system under pressure by constantly applying "pressure" to the tested system, investigate the maximum load that the system can bear under the current software and hardware environment, and help find out the bottleneck of the system, that is, we can simulate the huge working load to see how the application performs under peak usage.

Why stress testing?

In fact, stress testing has two purposes: one is to test whether the application will report errors and whether the process will hang up under the condition of high concurrency; Second, test the compressive capacity of the application, estimate the bearing capacity of the application, and provide the basis for capacity expansion for operation and maintenance students. The first point is easy to understand. Doing this well can ensure that there are no problems after going online. Explain the second point. We all know that no matter how excellent the architecture design is, no matter how well the code is written, there are always limited instances to deal with high and issue orders. Therefore, usually on the premise of meeting the first point, we calculate how many instances are needed to carry according to the possible high concurrency pressure, which requires us to press out the limit.

After the interface development is completed, the first pressure test can be carried out. This pressure test can be simply pressed on the machine. The purpose of the stress test is to check whether an error will be reported when the code is high and issued. In addition, compiled languages should observe whether there is a memory leak. Because the performance of this machine is limited, generally, the pressure test is carried out according to the number of processes of 100, 200, 300 and 500. If there is no error when it is pressed to 500, the fatigue test can be carried out to observe the memory occupation.

2. Knowledge analysis

What JMeter?

JMeter is an open source and free testing tool developed in Java. It is mainly used for function testing and performance testing (stress testing / load testing) And it is very easy to use JMeter to test the restful API. At the same time, JMeter can help you regression test your application. Verify that your program returns the expected value through the test script and assertions you created. For greater adaptability, JMeter allows you to create these assertions using regular expressions

1. Test plan: used to describe a performance test, including all functions related to this performance test. That is to say, all the contents of this performance test are based on one plan.

2. Threads (users)

1) Setup thread group can be used to perform pre-test operations. These types of threads perform periodic thread group execution before executing the test.

2) teardown thread group. Can be used to perform post test actions. These types of threads execute regular thread groups after the test.

3) Thread group This is the thread we usually add to run. Generally speaking, a thread group can be regarded as a virtual user group, and each thread in the thread group can be understood as a virtual user. The number of threads contained in the thread group will not change during test execution.

Ramp up period: the unit is seconds, and the default time is 1 second. It specifies the time it takes to start all threads. If you need JMeter to start all threads immediately, set this to 0

Number of cycles: indicates how many requests are executed by each thread.

3. Samplers, which are the basic elements of each test plan, work around these samplers: samplers execute requests (configuration based requests), which generate one or more responses, which will be analyzed later.

4. Listeners: responsible for collecting test results and being informed of the way the results are displayed. Listeners analyze results in the form of reports, tree structures, or concise log files. The function is to display the request result of the sampler, count some data (throughput, KB / S...), etc.

5. Assertions: used to determine whether the result of the request response is as expected and correct as expected by the user. Assertions are generally used to set checkpoints to ensure that the data interaction during performance testing is consistent with expectations.

6. Timers: define the delay interval between requests (threads) and simulate continuous requests to the server. It is used to set the waiting time between operations. The waiting time is a common means to control the client QPS in performance testing. If not specified, JMeter will execute the next request immediately after one request is completed without any waiting time.

7. Logic controllers: allows you to customize the behavior logic of JMeter sending requests. It can be used in combination with sampler to simulate complex request sequences.

8. The pre processor and post processor are responsible for completing the work before and after generating the request. The pre processor is often used to modify the settings of the request, and the post processor is often used to process the data of the response.

9. Configuration nodes by using configuration elements, you can pass different parameters to the sampler request. They provide a way to create variables (different and dynamic) that are then used by the sampler. Before the sampler is executed, these parameters are executed when the node to which the parameters belong is started; This is why the sampler can rely on these variables.

Test plan element execution order

1 - configuration node

2 – pre processor

3 - timer

4 – sampler

5 – post processor (only if results are available)

6 – assertion (only if results are available)

7 – listener (execute only if results are available)

3. Frequently asked questions

Distinction between throughput and bandwidth

Generate test plan (test script) with badboy

4. Solutions

Throughput and bandwidth are easily confused. Both are in Mbps Let's first look at the corresponding English, throughput: throughput; Bandwidth: Max net bitrate. When we discuss the bandwidth of a communication link, it generally refers to the number of bits per second that can be transmitted on the link. We can say that the bandwidth of Ethernet is 10Mbps. However, we need to distinguish between the available bandwidth (bandwidth) on the link and the number of bits (throughput) that can be transmitted per second in the actual link. We tend to use "throughput" once to represent the test performance of a system. In this way, because the implementation is affected by various low efficiency factors, a pair of nodes connected by a link with a bandwidth of 10Mbps may only achieve a throughput of 2Mbps. This means that an application on one host can send data to another host at a speed of 2Mbps.

6. Expand thinking

How to do the stress test of web application correctly

1) First, let's talk about how to generate pressure. There are many methods to generate pressure. Usually, you can write scripts to generate pressure. Robots can contract and receive packets from the server, or you can use existing tools (like JMeter and LoadRunner), so it's not difficult to generate pressure. The difficulty lies in whether the generated pressure truly reflects the actual user's operation scenario. For example, for games, the proportion of simple concurrent login scenario in the whole online environment may not be large (except for special cases such as new services). On the contrary, "login - start battle - end battle" Different users perform different actions. This "mixed mode" accounts for a larger proportion. Therefore, how to extract the specific proportion of the scene from the actual environment and convert this proportion into actual pressure is an important concern.

2) After the pressure is generated, we can usually get the performance data such as TPS and response delay, so how to locate the performance problem? TPS and response delay can only tell you whether there is a problem with the server, but they can't help you locate the problem. Behind these surfaces is the result of the comprehensive action of the whole background processing logic. At this time, you can first pay attention to the CPU, memory, IO and network of the system, compare these system data when TPS and delay reach the bottleneck, determine which part of the system causes the performance problems, and then return to the logic of the code to optimize these points one by one.

3) When the overall performance of the server can be relatively stable, you need to estimate the carrying capacity of your server. By generating real pressure and comparing system data, you can roughly have a real evaluation of the processing capacity of a single system, and then configure the number of servers in combination with the business scale.

7. References

https://www.jianshu.com/p/c2521b09f5fc

http://www.51testing.com/html/56/n-3723356.html

1. Distinction between throughput and bandwidth

When we discuss the bandwidth of a communication link, it generally refers to the number of bits per second that can be transmitted on the link. We can say that the bandwidth of Ethernet is 10Mbps. However, we need to distinguish between the available bandwidth (bandwidth) on the link and the number of bits (throughput) that can be transmitted per second in the actual link. We tend to use "throughput" once to represent the test performance of a system. In this way, because the implementation is affected by various low efficiency factors, a pair of nodes connected by a link with a bandwidth of 10Mbps may only achieve a throughput of 2Mbps. This means that an application on one host can send data to another host at a speed of 2Mbps.

2. What is the role of JMeter?

. JMeter can be used to test the performance of static or dynamic resources (files, servlets, Perl scripts, Java objects, databases and queries, FTP servers or other resources). JMeter is used to simulate adding high load on servers, networks or other objects to test the pressure capacity of their services, or to analyze the total performance of their services under different load conditions. You can use the graphical interface provided by JMeter to analyze performance indicators or test the behavior of servers / scripts / objects under high load.

3. Test plan element execution sequence?

1 - configuration node

2 – pre processor

3 - timer

4 – sampler

5 – post processor (only if results are available)

6 – assertion (only if results are available)

7 – listener (execute only if results are available)

Ppt link video link

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>