Project difficulties are challenging, complex, or uncertain problems and obstacles encountered during project execution that may affect the schedule, quality, cost, and achievement of the project's objectives.
I'll provide some of the more common hard questions here:
Specifically.
1. Technical difficulties
Some of the common technical difficulties and solutions are these:
-
Highly concurrent request issues: A large number of users accessing a server or application at the same time in a short period of time, resulting in a sharp increase in the load on the server, which may result in response delays, system crashes, and so on.
-
prescription: The following scheme can be used for the high concurrent request problem:
- Add Cache: Use caching to store hotspot data and reduce access to back-end databases.
- Restrictions and downgrades: Use token bucket or leaky bucket algorithms to limit the number of requests per unit of time; when an anomaly is detected in a service, automatically cut off the connection to that service to prevent the failure from spreading.
- asynchronous processing: Use message queues (e.g., RocketMQ, Kafka, etc.) to process tasks asynchronously, relieving the pressure of immediate processing.
- Database Optimization: This can be solved by using programs such as read-write separation, separate libraries and tables, and distributed databases.
-
prescription: The following scheme can be used for the high concurrent request problem:
-
Data and cache consistency issues: The problem of inconsistency between data in the cache and data in the database when the data in the database has been modified during the running of the program.
-
prescription: There are two common solutions:
- Use delayed double deletion and MQ to address data consistency issues.
- Use Canal to listen to the MySQL Binlog, then update the database to an MQ (e.g. Kafka), then update the Redis cache by listening for messages.
-
prescription: There are two common solutions:
-
Problems such as lost messages/backlogged messages: Message loss is the failure of a message to reach its destination during message delivery, which can be caused by network problems, system failures, etc. Message backlog is the accumulation of a large number of unprocessed messages in the message queue, usually due to the fact that the rate of message generation exceeds the processing speed of the consumer.
-
prescription:
- Lost Message Solutions: Use message acknowledgment mechanisms (producer message acknowledgment and consumer message acknowledgment), persistence, and multi-computer deployment to address this.
- Message Backlog Solution: This can be solved by using means such as extending consumer instances, optimizing consumer code, and limiting the rate at which producers can produce.
-
prescription:
2. Online debugging challenges
Some of the common online debugging problems and their solutions are these:
-
intermittent problem: Certain issues occasionally arise in production environment operation, such as the following:
-
Gap picture coverage issues: When user A generates an image, it is found that the intermittent generation is of user B's image.
- prescription: Problems with image name generation rules, which can be named using timestamps, and possible data overwriting problems in concurrent environments.
-
Problem of inefficiency of intermittent queries: The problem of executing an operation inefficiently for a random period of time.
- prescription: Set up alarms and monitors to check logs and analyze system resources to identify problems when they occur. These problems may be database resource exhaustion queuing problems, may also be memory resources are used up resulting in low operating efficiency, there may be CPU burst resource consumption and other issues, so you need to determine the problem according to the logs and then optimize accordingly.
-
Intermittent OOM issues: After the project goes live, every once in a while (the time may not be fixed) it causes OOM (Out Of Memory) memory overflow issues.
-
prescription: There are many causes of OOM problems, so the common ideas and steps for solving OOM problems are as follows:
- Diagnosing OOM Problems: Use tools such as VisualVM, JProfiler, or MAT to generate a Heap Dump to analyze memory usage and determine the cause of the OOM problem.
- Optimized code: Optimize the corresponding code based on the diagnosed OOM problem.
- Adjusting JVM Parameters: Adjusting heap space, new generation occupancy, garbage collector, etc. to prevent some OOM problems.
-
prescription: There are many causes of OOM problems, so the common ideas and steps for solving OOM problems are as follows:
-
Gap picture coverage issues: When user A generates an image, it is found that the intermittent generation is of user B's image.
-
Some complex issues: There are many complex issues, some of which are listed here:
- Distributed Transaction Problems with MySQL and Redis.
- Inefficient and OOM issues with high volume data import and export.
3. Performance issues
Some of the common performance issues are these:
-
Program performance issues: Inefficiency, sluggish response, excessive resource consumption, or inability to meet expected processing speeds and throughputs that are exhibited when a program is running. Common program performance problems include these:
- High CPU utilization: Some calculations or logic in the program cause the CPU to be under high load for long periods of time.
- memory leak: Failure to properly free memory that is no longer in use, resulting in a gradual decrease in available memory.
- Frequent I/O operations: e.g., a large number of file reads and writes, network requests, etc., causing the program to block.
- Poor database query performance: Unreasonable SQL queries, lack of indexes, etc. lead to slow database operations.
- Poor choice of algorithms and data structures: For example, inefficient algorithms are used or data structures that are not suitable for the current scenario.
- Thread Rivalry and Deadlocks: Resource competition and deadlocks between threads in a multithreaded environment can affect the efficiency of program execution.
- The solution is as follows:
- performance analysis: Use tools such as JProfiler (Java), VTune (general purpose), etc. to monitor program performance metrics and identify performance bottlenecks.
- Code Optimization: Optimize algorithms and data structures and choose more efficient implementations; reduce unnecessary calculations and repeated calculations.
- memory management: Release memory resources that are no longer in use in a timely manner to avoid memory leaks; use caching wisely to avoid over-occupying memory.
- I/O Optimization: Asynchronous I/O operations are used to avoid blocking; batch processing of file reads and writes and network requests.
- Database Optimization: Optimize SQL query statements, add appropriate indexes; you can use read-write separation, separate libraries and tables, distributed database and other solutions to solve the problem.
- Multi-threaded optimization: Avoid excessive thread synchronization and reduce lock contention; check for and resolve deadlocks.
-
Database performance issues: The slow response time, high resource utilization, low throughput and other undesirable conditions exhibited when the database handles data operations (e.g., queries, insertions, updates, deletions, etc.) affect the overall performance of the system and the user experience.
- The solutions are these:
- Optimizing Query Statements: Avoid unnecessary subqueries and complex functions; make sure that query conditions are properly indexed.
- Building and Optimizing Indexes: Create indexes based on fields that are frequently used for queries, joins, and sorting.
- Adjustment of database configuration: Properly configure parameters such as memory buffers, number of connections, thread pools, etc.
- databases and tables: When the amount of data is too large, the table is divided horizontally or vertically according to certain rules, or the database is vertically split and horizontally split function.
- Resolving Lock Competition: Minimize transaction execution time and reduce lock holding time; use appropriate locking levels, such as row locks rather than table locks.
- Monitoring and Analysis: Use the performance monitoring tool that comes with the database or a third-party tool to analyze performance indicators on a regular basis and find timely solutions to problems.
- The solutions are these:
homework after school
The above problems are just a throwback, you can combine the above programs with your own project to expand the project difficulties and solutions. Then how to deal with the last two problems: security problems and resource allocation problems? Welcome to the comments section to discuss and add oh.
This article has been included in my interview mini-site, which contains modules such as Redis, JVM, Concurrency, Concurrency, MySQL, Spring, Spring MVC, Spring Boot, Spring Cloud, MyBatis, Design Patterns, Message Queuing and more.