DOCX

H5 caching mechanism analyses mobile Web load performance optimization

By Jimmy Burns,2015-09-12 13:26
16 views 0
H5 caching mechanism analyses mobile Web load performance optimization

    Event-driven architecture is a popular mode of distributed asynchronous architecture, used to build the application of high scalability.It has high adaptability, applies to small applications, also suitable for large, complex applications.Event-driven architecture is made up of highly decoupled, target a single, components can be asynchronous receive and handle events.

    The architecture: there are two main topology mediator and broker.When you need the orchestration of the multiple steps into an event when using mediator, when not using the mediator will be more than one event together with a broker.Architecture characteristics of these two kinds of topological structure and the implementation way is different, you need to know which one is the right of your scene.

    Meditor topology

    Mediator topology used in this scenario, events have multiple steps, require a certain level of choreography between steps.For example, a stock exchange event, you first need to verify the validity of the transaction, check whether conform to the rules, will be assigned to brokers trading, calculate commissions, finally complete the transaction.These steps need to pass a certain level of arrangement, determine the sequence of steps, which steps are executed serially, what steps can be executed in parallel.

    Mediator topology architecture includes four types of components: the event queue (event the queues), event intermediary (event mediator), an event channel (event channels), the event handler (event processors).Event stream from the client to send events to queue time, the event queue will send events agencies, intermediary receives initial events, send some additional asynchronous events to the event channel to perform the processing of each step.Event handler to monitor the event channel, receive from events of mediation, execute the business logic to handle events.

    Figure 1 mediator topology structure of event-driven architecture (Event - driven architecture mediator topology)

    In the event driven architecture of a dozen or even hundreds of the event queue is common.The model does not limit the realization way of message queue component can be a message queue, the message queue), web service endpoint (web service endpoint), or a combination of several ways.

    There are two types of events in the model, the initial event (initial event) and process events (processing event).Initial is intermediary receives the original events, and event handling is mediation generated receiving events, event processing components.

    Event the mediation component used to organize the original event contains a number of steps.For every step of the initial event, the mediation would send a event handling to an event channel, receiving and processing by the event handler.Note that the mediation actually wrong initial event logic processing, but it know the initial event is divided into several steps are needed to deal with.

    Were the event channel intermediary for asynchronous passing the time processor original one step corresponding processing events.Event channel can be either a message queue, the message the queues) can also be a message subject (message switchable viewer), although widely used message theme in the mediator topology structure, in order to handle events can be handled multiple event handlers.

    Event processing component contains business logic needed for the process events.Each processor is self-contained, independent, highly decoupled, perform a single task.Although the event processing component granularity can be small can also is very big, but each event processing components should be able to handle a single business tasks and don't need to rely on other event processing components to complete together.

    There are many kinds of way to accomplish this event agencies.As an architect, you need to understand the details of each implementation, be sure to select appropriate way with business requirements.

    The most simple and common is open source Integration components such as Sping Integration, Apache Camel, Mule ESB.They flow of events is often the Java language or DSL (domain specific language).More complex with the BPEL (business process execution language) plus a BPEL engine, such as the open source Apache ODE.BPEL is a kind of XML language, used to describe the data and the steps needed to processing the initial event.Larger applications may be used in complex event scheduling the BPM (business process manager) as the jBPM.

    For example, suppose that in the insurance company for insurance, now decided to move.Initial events may be called the relocation event, the event contains a series of steps is shown in figure 2.For each step of the initial event agency to create a process events, send event handling to an event channel, waiting for the corresponding event handlers for processing.Some of the event handling can be performed at the same time.

Figure 2 mediator topology case

    The broker topology

    The difference between the broker and mediator mediation is that there is no central events, by contrast, the message flow in the chain of lightweight message broker (message broker) (such as the RabbitMQ, ActiveMQ, HornetQ) in the event processing components.This topology structure in the flow of events is relatively simple, and don't want to use (or not) is very useful when centralized event arrangement.

    In the broker topological structure has two main components: the agent (broker) component and event handlers (the event processor) components.Broker component can be centralized, also can be federated, it contains all the event channel in the flow of events.Broker component of the event channel can be a message queue (message the queues) or message subject (message switchable viewer) or a combination of both.

    Figure 3 event-driven architecture of broker topology (Event - driven architecture broker topology)

    From broker topology structure, you can see that there is no event in the middle of the mediation component to control the initial event and choreography, but each event processing components processing an event and release a new event shows that it is processed.For example, an equity portfolio balance the event handler receives the initial event stock split, against the initial event, time processor can do some portfolio rebalancing, then release agent to rebalance a new event protfolio, by other processors for processing.Note event handlers publishing events may occur sometimes, but there is no other processors receive events.In this update application or provide some future function is common and extension.

    In the same case as the mediator of the broker structure.Because the broker topology without central mediation to receive initial events, the customer - the process component directly receive events, change the user's address, and then send change address expressed has changed the user address.In this case, there are two event handlers can receive processing change the address, the quote process and claims process.Quote process components based on the change of address to recalculate the insurance rates, and publish the recalc quote event shows that it has processing is completed;Claims process components updated insurance claims and release the update the claim events.New events are other

    components to receive and process, finally the chain of events across the entire system released until there is no new event.(PS: don't know foreign situation, this case really didn't understand...).

    Figure 4. Case broker topology

    As can be seen from the figure 4, the broker is topology processing business event chain.It can be seen as the relay race, a player with a baton run after a certain distance to the next player, know all the players have finished the race.In the relay race, a player handed the baton means he complete the competition.

    Matters needing attention

    Event-driven architecture model to implement is relatively complex, mainly because of its characteristics of the asynchronous distributed.To implement this mode, the need to deal with a large number of distributed architecture, such as the usability of the remote processing, the lack of response, failure of broker reconnection problems, etc.

    Choose a need to consider this model is lack of the business logic of the single atom transactional.Because the event processing components are highly decoupled and distributed, complete a transaction through their common unit is very difficult.Therefore, choosing the pattern design, must constantly consider what events can or can not run independently, accordingly the granularity of planning the event handler.

    Maybe the pattern is the most difficult event processing components of the contract between the creation, maintenance and management.Every event has a corresponding contract (data values passed to the event handler and data format).At the outset the selected data format (XML, JSON, Java Object, etc.) and the establishment of contract version of the strategy is very important.

    Pattern analysis

    The following table shows the layered architecture model of general architectural features of rating and analysis.

    The overall flexibility

    High grade:

    Analysis: the overall flexibility is quick response ability to the environment changes.Due to events of blow component is a single goal, and each other completely decoupled, usually changes between isolated within the component or a few event handlers, can not affect other components quickly modified.

    Easy to deploy

    High grade:

    Analysis: due to decoupling between event components, deployment of this model is relatively easy.Broker topology than mediator fabric structure is more easy to deploy, intermediary to some extent because events and event handlers are coupled, modify the event processing components may also need to modify the event intermediary, need to deploy processing components and events at the same time the mediation.

    testability

    Low grade:

    Analysis: although the independent unit testing is not very difficult, but need special test tools to generate the client or events.The characteristics of asynchronous also lead to test is more complex.

performance

    High grade:

    Analysis: as all of the information architecture, may realize the architecture of the performance is not very good, but due to the characteristics of asynchronous, the performance of this architecture is generally high.In other words, the execution decoupled, parallel ability of asynchronous operations over the message queue access costs.

    scalability

    High grade:

    Analysis: the pattern of extensibility, highly independent and decoupling from the event handler.Each event handler can be independently extend, scalable granularity is very small.

    The development of ease

    Low grade:

    Analysis: the creation of the contract, and asynchrony, event handler does not response or proxy fails need more error handling, makes the development process is more complex.

Report this document

For any questions or suggestions please email
cust-service@docsford.com