Message queue test scenario and redis test scenario

insert image description here


1. Message queue test scenario

1. What is a message queue. How did you test it?

Problem-solving ideas:
What is a message queue.
Message queue application scenarios.
List of message queue test points.

2. What is a message queue

Broker: message server, which provides message core services.
Producer: message producer, the initiator of the business, responsible for producing messages and transmitting them to the broker.
Consumer: The message consumer, the business processor, is responsible for obtaining messages from the broker and performing business logic processing.

insert image description here

3. Application scenario of message queue

Asynchronous communication
Traffic peak shaving
Application decoupling
Load balancing
Data synchronization

4. Test point of message queue

Type important point test point
producer timing Messages are pushed in different timings, whether the sequence is consistent with expectations
Data correctness Is the content complete?
Does the content meet the needs
to push Is there a retry for push failures?
consumer correctness normal consumption information
Whether to clear the message after it is consumed
The information received by the consumer is consistent with that of the producer
Consumers are blocked, how to deal with it .
Idempotent (duplicate message received)

2. Redis test scenario

1. Introduction to Redis

Excellent read and write performance.
Rich data types.
Redis supports data backup.
Data expires automatically.
Publish Subscribe.
distributed.

2. Redis application scenarios

Scenarios with more reads and fewer writes, and strong concurrency. (Second Kill, Hot Search on Weibo)
Time-sensitive business scenarios. (SMS verification code)
Sort the ordered collection data type. (Leaderboard)
does not have high requirements for timeliness. (Counter)
Session Session cache.
message system.
The single-threaded feature can be naturally used as a distributed lock.

3. The interaction process between backend service and database (without redis)

insert image description here

4. The interaction process between backend service and database (redis)

insert image description here

4. Redis test scenarios and interview questions

a. Does your Redis use the elimination cache or the update cache? What is the difference between the two? Please explain in details.

Problem-solving ideas:
prerequisite: understand the process of reading and writing cache.

Cache operation process - read

There is data in the cache.
There is no data in the cache.

insert image description here

Cache operation process - write (eliminate cache)

Advantages: Simple operation and good performance.
Disadvantage: At least one cache miss will occur. (When a large number of requests access the database, the database pressure is very high)

insert image description here

Cache operation process - write (update cache)

Advantages: Basically, there will be no cache miss.
Disadvantages: The cache is updated every time the database is updated, which affects performance.

insert image description here

The difference between eliminating cache and updating cache
Eliminate cache: better performance, at least one cache miss (used a lot)
Update cache: poor performance, basically no cache miss

b. Redis cache invalidation problem: How to locate the Redis cache invalidation problem (cache is broken)? And how to solve the cache invalidation problem?

Problem-solving ideas:
What is cache invalidation?
After the cache is unavailable, a large number of concurrent requests are sent to the database.

insert image description here

What is the reason for the cache invalidation?
Cache expired.
Redis exception.
network anomaly.
cache update

insert image description here

How should cache invalidation research and development be handled, and how should testing be tested?
Downgrade: Disable some interfaces and open core interfaces.
Circuit breaker: Disable some services and open core services.

Cache invalidation related test methods

Sort out the list of core services in the system (usually directly ask R&D to give the corresponding list).
Sort out the list of core interfaces in the service (usually directly ask R&D to give the corresponding list).
Simulate the failure of Redis to verify whether the core service and core interface can still run normally.

c. The difference between Redis breakdown and penetration

The difference between Redis breakdown and penetration, how to design use cases and complete the test?

Problem-solving ideas:
the concept of breakdown, how to design test cases.
The concept of penetration, how to design test cases.

insert image description here
Test case steps for the breakdown scenario
Obtain a list of hot keys (acquired after communicating with O&M).
Simulate the scenario where the hot key fails (such as logging in to Redis and deleting the hot key directly).
Check whether R&D has a corresponding fault-tolerant mechanism to ensure the normal operation of the service.

insert image description here
insert image description here
Test case steps for penetrated scenarios
Continuously access the interface of the corresponding service, and pass a query request for non-existent data.
Check whether R&D has a corresponding fault-tolerant mechanism to ensure the normal operation of the service.

Summary of Breakdown and Penetration

type penetrate breakdown
test target Check whether R&D has a corresponding fault-tolerant mechanism to ensure the normal operation of the service. Check whether R&D has a corresponding fault-tolerant mechanism to ensure the normal operation of the service.
Test Methods Continuously access the interface of the corresponding service, and pass a query request for non-existent data. Simulate the scenario where the hot key fails (such as logging in to Redis and deleting the hot key directly).

Guess you like

Origin blog.csdn.net/YZL40514131/article/details/130610167