Considerations when designing backend architecture

· Tech· CS
CSArchitecture

We have summarized the things to consider when designing a back-end architecture and how to best deal with each situation. To operate one application, a single server can be configured with DNS, web server, and database that are linked to the application.

Which database should I use?

The choice of database will depend on the service, and according to CAP theory, availability, consistency, and partial defects must be considered. Depending on which properties are most important, we can choose the database. If availability and speed are priorities over consistency, you can use NoSQL, and in general, the RDBMS we use is suitable for programs that place more emphasis on the consistency aspect. In our experience, RDBMS was used because consistency is important in cases where everyone had to check the same information, and NoSQL was used for databases in environments where the data in all nodes was not the same but had large volumes and little change in cases where the database load had to be reduced.

  • Availability: When all nodes must respond normally
  • Consistency: when all nodes have the same data
  • Partial fault or split durability: Due to network characteristics, it must operate even if there is a communication failure between nodes

What is the difference between partition durability and availability?

Partition durability means that in a distributed system, the system continues to operate even if any node fails. This means that if part of the system fails, other nodes must be able to continue performing their function. On the other hand, availability means that the system must be available at all times. That is, users must be able to access the system and use the service. Therefore, availability refers to the availability of all services and features required for the system to function as a whole. Partition durability means ensuring that the system can continue to operate even if part of the system fails, while availability means that the system as a whole must always be available. However, in the article CAP Theorem, Misleading and Truth, the definition of partition durability is used differently in each article, and PACELC is explained in that the question of whether there may be a network failure is a matter that must be selected because no program is perfect. In a failure situation, A and C conflict and one must be chosen, and in a normal situation, one must choose between latency and consistency rather than availability. It should be taken into account that it is not clear to apply RDMBS as a CA in that CAP itself must consider not only the situation of the distributed system but also the network state.

Let’s also consider the scalability of the service scale

As the size of the service increases, the design must take into account the need to expand the server. Horizontal expansion means adding servers, and vertical expansion means adding CPU and memory of the server. In the case of horizontal expansion, servers are added, so it can be managed in various ways, such as separating customers accessing specific pages or separating customers. Like a slave server, it can also be used as a substitute for a master server when a problem occurs with the server. Vertical expansion can be more expensive than horizontal expansion, and because one server handles more volume, server problems can lead to major service failures. Another drawback is that doubling vertical expansion cannot be seen as doubling performance.

  • In large-capacity services, the database mainly has a high read ratio, so the main and secondary database servers are distributed and managed by having database servers that handle only read operations.
  • Use cache. Caching frequently used data in advance without direct database access has the advantage of being faster and reducing load. However, it has the disadvantage that consistency problems between the cache and DB may occur.

Utilization of CDN

CDN stands for Contents Delivery Network, which caches content such as web pages, images, and videos from geographically nearby proxy servers and ensures that they can be processed quickly according to user requests. Companies that provide CDN vendor services include AWS CloudFront, Akamai Technologies, and Cloudflare.

  • For an example of how to use AWS CloudFront, first set the delivery content type and content source in the AWS CloudFront console. Configure default cache behavior to specify how CloudFront handles requests for content, and customize distribution settings such as SSL certificates, price tiers, and error pages. Once your distribution is created, you can access your content using the domain name that CloudFront provides.

Transaction and DB lock settings

When designing the backend, it is very important to decide how to take transaction units. If the transaction unit becomes unnecessarily large, an unintended deadlock may occur, and transaction time may increase, which may result in performance degradation if there are an excessive number of requests for the same transaction. Also, since the transaction unit is small, there are multiple transactions in one business flow, so if an intermediate failure occurs, a problem may arise where part of the business is rolled back while still being performed. Database lock settings are also important. Using pessimistic locking can reduce performance because locks are created unnecessarily even when there is no race. Conversely, optimistic locking checks for isolation violations when a transaction is committed, so rollback processing may reduce performance in competitive situations. Therefore, it is necessary to set appropriate locks by determining competition, lock range (row, page), speed, etc. There is also a way to use a distributed lock. A distributed lock is a method of controlling access to shared data from multiple servers so that only one computer can access it. If it is simply an application with many queries, the performance load can be reduced by using distributed locking to process access, and RDBMS using optimistic locking.

Comments

No comments yet. Be the first!

    164 posts in 테크

    15 / 164