Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The growth of PHP (2)-- SOA&RESTful Software Architecture

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Have you ever encountered that data from the same database have to achieve the same function again every time you make a product, and each product has to write the same functional module separately (such as logging in, obtaining product list, etc.). Many functional modules written before can no longer be reused, and after working for several years, the company has not precipitated anything that can be reused.

If you have encountered a similar situation, maybe you should pay attention to SOA (Service-Oriented Architecture)-- Service-oriented Architecture. This is not a specific technology, but a design idea. His main idea is to separate the service from the project and make it into an interface form for other projects to call. This benefit is obvious. First, as long as the interface form is agreed, any language can call each other. Second, maximize the reuse function module; third, can be expanded horizontally and vertically, and so on. At this time, you may remember that Web Service is coming, and it is mainly based on SOAP to be called through the HTTP protocol. This form has many disadvantages, such as development trouble, to generate a very large WSDL file, the generated data format is very complex, is there a simple and secure way, of course, RESTful (Representational State Transfer) describes an architecture-style network system. Many companies' API is developed in this form, such as Weibo API,QQ open platform, Taobao development platform, etc., then what are its advantages? first of all, it is based on the HTTP protocol, through the POST, GET, HEAD, PUT, DELETE, OPTIONS, TRACE and other requests to deal with resources, and then return to a common data format, such as XML/JSON, so that no matter it is the Bhand Scent Chand S framework can be well supported. Let's talk about RESTful architecture design.

First of all, the architecture is as follows:

You need to assign an appKey and an appSecret to each program, then access the service through URL, and finally the service returns data (in JSON / XML format).

Possible problems:

1. Security

When the requester sends a request, the server wants to verify the validity, so how to verify it? most schemes follow OAuth (now it is generally upgraded to OAuth3.0). Here is a simple way I designed that can be used in small applications.

2. Request control

The API cannot be called indefinitely, otherwise the service will be slow, so there are many ways to limit requests. You can use Nginx's limit module to limit the frequency of calls and the maximum number of connections.

3. Service expansion

First of all, for future service upgrades, you need to make a very good design of the interface to avoid subsequent changes to the URL. Here, it is recommended to apply more design patterns to program design, while with the increasing number of visits to the service, you need to upgrade the framework of the service. This can refer to my "Project growth" feature article.

At present, the SOA architecture is very mature, so we can do more research and discussion.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report