The method and system of commodity price real-time exhibition is provided
Technical field
The present invention relates to the displaying field of e-commerce industry web site commodity price, relate more specifically to provide commodity price
The method and system of real-time exhibition.
Background technology
In recent years, with the rise of e-commerce, " price war " has become a kind of heavy of major electric business enterprise initial stage competition
Want means.Price receives user's concern as a kind of Sensitive Attributes of commodity.In real time, accurate price displaying is extremely important,
One of the main target pursued as e-commerce venture's price system.Due to influencing the factor of price (for example, e-commerce is looked forward to
Price adjustment that industry business personnel carries out self-operation commodity, promotion, the price that open platform third party businessman carries out its commodity
Adjustment, promotion, promotion is automatic expired, promotes artificial delete etc.) the more and moment is likely to change, therefore to all the time
Price request will ensure that complete real-time will integrate all changes factor and calculate, and calculate the valence of some commodity of this at moment
Lattice respond the price request at this moment.With increasing for Internet user, billions of price requests is had daily, for
Each price request, which calculates, can once bring back-end services huge calculating pressure, so that calculation of price application system
It can't hold out against so huge pressure and the problems such as response is slow, service is unavailable occur.Today of internet prosperity, price displaying are prolonged
Late, price displaying service is unavailable can bring customer experience no small negative effect.
The prior art related to the present invention
Internet industry solve improve response speed, accelerate the Web service response time, mitigate source station pressure in terms of
There is ripe technology.CDN (Content Delivery Network content distributing networks) technology can make in different geographical
User to obtain required information nearby foregoing to solve the problems, such as.CDN is by increasing in existing Internet
Add one layer of new CACHE (caching) layer, the content of website is published to CACHE (caching) sections closest to user network " edge "
Point, before the deadline (TTL) access repeated is not necessarily to obtain data from source station, user can obtain required content nearby,
Improve the response speed that user accesses website, it technically comprehensively solve since network bandwidth is small, user's visit capacity is big, site
The slow problem of response that reasons make user access website such as it is unevenly distributed.Fig. 1 is the structure of content distributing network (CDN)
Figure.As shown in Figure 1, it has done node to respond the user of different regions different operators network respectively from operator and region
Request.
The technical solution of the prior art
Current more Internet enterprises have been all made of CDN technologies when doing similar price display systems.Fig. 2 shows
Price display systems in the prior art.As shown in Fig. 2, central machine room is for disposing calculation of price application service, peripheral CDN sections
(TTL) caches price to point before the deadline, and the calculation of price application service acquisition price that source station is returned to after failure continues to be buffered in
In the caching of the CDN node of periphery.
The shortcomings that prior art
Any type technology or system have certain applicable scene.The price system of e-commerce venture is due to its sensitivity
Property should be real-time system, CACHE (caching) nodes of CDN are since there are the setting of effective time (TTL), different nodes
Setting there may be inconsistent, even if the same node since necessarily there is of short duration time difference in the presence of effective time (TTL),
A lot of nodes are also long in effective time the considerations of mitigating source station pressure (TTL), this is sacrificed much to a certain extent
Real-time.
Therefore, it is necessary to a kind of method and systems being capable of providing commodity price real-time exhibition.
Invention content
According to one embodiment of present invention, a kind of system for providing commodity price real-time exhibition is provided, including:
Real-time unit, price data of the real-time unit for obtaining commodity in real time, and include application module and data storage mould
Block;Price source station, the price source station connect with the real-time unit communication and in response to asking to described real-time
Unit provides the price data;Price updating message queue module, the price updating message queue module and the price
Source station communicatedly connects, and is configured to when the real-time unit obtains the price data, and the price source station is by quotient
In price updating message queue module described in product number asynchronous write;Write-back application, the write-back are applied for from the price
New information Queue module obtains the goods number, and further obtains recent quotation, to carry out write-back and update the reality
The price data in the data memory module in Shi Danyuan.
Preferably, the application module is further configured to:The request to the price data of commodity is handled, to institute
The commodity of request are numbered, and the current price data of the commodity is obtained from the data memory module;If described
Current price data is effective, then the application module using the current price data and returns to the request;And such as
Current price data described in fruit is invalid, then the application module initiates the recent quotation to the commodity to the price source station
Request, and return to obtained recent quotation.
Preferably, the application module is further configured to:If the price source station normally returns to request, normally
Use the recent quotation;And if the price source station is without return or time-out, the real-time unit returns described current
Price data.
Preferably, the system further comprises:Backend application, the backend application change commodity price for providing
Relevant business operation is pushed to the price updating message queue module, to obtain the newest variation of price.
Preferably, the price data includes current price and nearest expired time stamp.
Preferably, if current time is less than or equal to the nearest expired time stamp, the current price data
Effectively;And if current time is more than the nearest expired time stamp, the current price data is invalid.
According to another embodiment of the invention, a kind of method for providing commodity price real-time exhibition is provided, is wrapped
It includes:The application module of real-time unit asks to obtain the price data of commodity in real time to price source station;The price source station in response to
It asks to provide the price data to the real-time unit, and when the real-time unit obtains the price data, it is described
It price source station will be in goods number asynchronous write price updating message queue module;And write-back is applied and disappears from the price updating
It ceases Queue module and obtains the goods number, and further obtain recent quotation, to carry out write-back and update the real-time unit
In data memory module in price data.
Preferably, the method further includes:The price of the application module processing of the real-time unit to commodity
Requested commodity are numbered in the request of data, and obtain the quotient from the data memory module of the real-time unit
The current price data of product;If the current price data is effective, the application module uses the current price
Data simultaneously return to the request;And if the current price data is invalid, the application module is to the price source
It stands the request initiated to the recent quotations of the commodity, and returns to obtained recent quotation.
Preferably, if the price source station normally returns to request, newest valence described in the application module normal use
Lattice;And if the price source station returns to the current price data without return or time-out, the real-time unit.
Preferably, the method further comprises:It will be provided by backend application and relevant business behaviour changed to commodity price
It is pushed to the price updating message queue module, to obtain the newest variation of price.
Preferably, the price data includes current price and nearest expired time stamp.
Preferably, if current time is less than or equal to the nearest expired time stamp, the current price data
Effectively;And if current time is more than the nearest expired time stamp, the current price data is invalid.
According to the detailed description below the disclosure and attached drawing, mesh other to those skilled in the art
, feature and advantage will be apparent.
Description of the drawings
Attached drawing illustrates the embodiment of the present invention, and is used to explain the principle of the present invention together with specification.In the accompanying drawings:
Fig. 1 is the structure chart of content distributing network (CDN).
Fig. 2 shows price display systems in the prior art.
Fig. 3 shows the schematic diagram of real time price system according to an embodiment of the invention.
Fig. 4 is the schematic diagram of the data refresh mode of data memory module according to an embodiment of the invention.
Fig. 5 shows the flow chart according to an embodiment of the invention for providing the method for commodity price real-time exhibition.
Fig. 6 shows the performance of pressure test under real-time cell mesh scene according to an embodiment of the invention.
Specific implementation mode
A kind of method and system that commodity price real-time exhibition is provided is disclosed according to an embodiment of the invention.It is retouched following
In stating, for illustrative purposes, multiple details are elaborated to provide the comprehensive understanding to the embodiment of the present invention.However,
For those skilled in the art it is readily apparent that the embodiment of the present invention can be realized without these specific details.
It is overall to constitute
Fig. 3 shows the schematic diagram of real time price system 300 according to an embodiment of the invention.
As shown in figure 3, real time price system 300 applies 307, price more by real-time unit 301, price source station 303, write-back
The part such as new information Queue module 305, backend application 309 forms.
Real-time unit 301 is the key component of whole system, the price data for obtaining commodity in real time.Real-time unit
301 include application module 311 and data memory module 313.All requests can all initially enter the application mould of real-time unit 301
Block 311 is handled.The application module 311 of real-time unit 301 is to all request parallel processings, in processing to the commodity of request
It is numbered and obtains the current price data of the commodity from data memory module 313.The price data for example may include
Current price and nearest expired time stamp.If current price data is effective/not out of date, for example, current time be less than or
Person stabs equal to nearest expired time, then uses the price data and return to price request;If current price data were invalid/
Expired, for example, current time is stabbed more than nearest expired time, then application module 311 is initiated to price source station 303 to recent quotation
Request, and the recent quotation asked to price source station 303 is returned to request;If price source station 303 normally returns to request,
Then recent quotation described in normal use, if price source station 303, without return or time-out, real-time unit 301 returns to legacy data
(that is, stale data).313 full dose of data memory module of real-time unit 301 stores price data, and the price data of storage is by rear
Write-back is held to come in using 307 write-ins, the data being written are latest datas at that time, and mould is applied for real-time unit 301
Block 311 uses.
Price source station 303 communicatedly connect with real-time unit 301 and for providing calculation of price service.Price source station
303 obtain recent quotation mainly for real-time unit 301, are the infrastructure components of whole system.Real-time unit 301 is obtained newest
The goods number of price, price source station 303 can make in the goods number asynchronous write price updating message queue module 305
Write-back obtained from message queue module 305 using 307 include the goods number message, and further obtain newest valence
Lattice, to carry out write-back and to update the price data in the data memory module 313 of real-time unit 301, to reduce reality to the greatest extent
Shi Danyuan 301 goes back to source request price source station 303 again because price data is expired.
Write-back, from 305 inner acquisition price updating task of price updating message queue module, calculates price at that time using 307
Data (price and nearest expired time stamp) are simultaneously updated into the data memory module 313 of real-time unit 301, it is whole system
In indispensable significant components.
Price updating message queue module 305 carries the storage for the goods number for needing to update price, is back that source services
With the significant components of write-back service decoupling.Meanwhile the variation task of commodity price can also be write price updating by backend application 309
In message queue module 305, write-back service is allowed to update the data.It is higher that priority can also be built depending on queue message consumption
Queue is reacted to real-time unit 301 more in real time so as to rear end to the change of price.
Backend application 309 is provided is pushed to price updating message queue module to the relevant business operation of commodity price change
305, to obtain the newest variation of price.Backend application 309 is mainly directed towards business personnel.
Data memory module
Data memory module 313 has used single unit in real time to deposit the modes of full dose data, due to particular commodity price number
Full dose can be less stored completely according to occupied space.The application module 311 on unit 301 is also from this unit using data in real time
It is obtained in data.
The data that units use different in real time by the way of master-slave synchronisation, leader follower replication chain may have it is multiple, data
There are one root nodes.Data can accomplish approximate strong consistency on the duplication chain derived from root node.
Fig. 4 is the schematic diagram of the data refresh mode of data memory module 313 according to an embodiment of the invention.Data are deposited
The data update of storage module 313 takes the mode of read and write abruption, and all write-ins can all write on host node, all readings
All it is to obtain data from node, further increasing the safety of data in this way.In detail as shown in Figure 4.
Fig. 5 shows the flow chart according to an embodiment of the invention for providing the method for commodity price real-time exhibition.
As shown in figure 5, in step 502, real-time unit 301 asks to obtain the price data of commodity in real time to price source station 303.Then,
In step 504, price source station 303 is to the offer price data of real-time unit 301 and asynchronous by goods number in response to the request
It is written in message queue module 305.In step 506, write-back is applied from message queue module 305 and obtains goods number, goes forward side by side one
Step obtains recent quotation, to carry out write-back and update the price data in the data memory module 313 in real-time unit 301.
Preferably, request of the processing of application module 311 of the real-time unit 301 to the price data of commodity, it is right
Requested commodity are numbered, and the current price data of the commodity is obtained from the data memory module 313;If
The current price data is effective, then the application module using the current price data and returns to the request;With
And if the current price data is invalid, the application module 311 is initiated to the price source station 303 to the commodity
Recent quotation request, and return to obtained recent quotation.It is described to answer if the price source station normally returns to request
The recent quotation described in module normal use;And if the price source station is returned without return or time-out, the real-time unit
Return the current price data.
Specific implementation
Real-time unit 301 is unquestionably that this technology invents most important part.Real-time unit 301 must to the processing of request
It need can meet high performance basic demand.In the application module 311 of real-time unit 301, it is widely used to be interconnected net enterprise
Nginx can meet high performance requirement.Nginx has committed memory few, stable relative to traditional Apache, lighttpd
Property it is high, processing concurrent capability is strong the advantages that, its Nginx in processing user's request has fully used asynchronous logic, in Linux behaviour
Make to have used the multichannel I/O Ready of non-obstruction that (epoll) case mechanism is notified so that efficiency is very high in system.
It is preferred in the data storage section Redis of real-time unit, Redis is a high performance memory grade K/V data
Library provides abundant storage organization type, disclosure satisfy that requirement.It is Lua, Lua using with " bridge " that data interact
A kind of succinct, lightweight, embedded, expansible script, it can easily be embedded in " host " C language (Nginx's
Write language) the middle extension as host language.Three of the above component has relatively good performance in aspect of performance.
Fig. 6 shows the performance of pressure test under real-time cell mesh scene according to an embodiment of the invention.Fig. 6's
Abscissa is concurrent user number in coordinate system, and ordinate is the number of requests (i.e. QPS) of unit interval (per second).As shown in fig. 6,
With the trend for being continuously increased QPS and reduction after first increase being presented of concurrent user number, and under a certain specific concurrent user number
QPS reaches peak value.(1) the specific concurrent user number is can be seen that from the specific concurrent user number and QPS peak values obtained
Respective value in ultra-traditional application remote with QPS peak values, that is to say, that there is stronger processing energy according to the technique and scheme of the present invention
Power;(2) it in the case where obtaining the specific concurrent user number and QPS peak values, can be closed according to the flow of anticipation request to build
The cluster for managing number servers, to have directive significance to rational cluster scale.
It is the Web applications realized by Java that price source station 303 and write-back, which apply 307,.It needs all to do for extension
Clustered deploy(ment).
Technical solution of the present invention fundamentally solves the problems, such as poor in timeliness caused by traditional scheme and due to request
Measure it is huge and to the stress problems that source station is brought, thoroughly meet the demand of the real-time shown to commodity price, and can basis
The demand that flow increases carries out dilatation.
Traditional price display technique and scheme are improved and broken through in technical scheme, the price made is more
New promptness is significantly improved, and brings good user experience.These are to categories such as e-commerce industry commodity prices
The experience for showing user of property plays facilitation.
Above-described embodiment is only the preferred embodiment of the present invention, is not intended to restrict the invention.To those skilled in the art
It is readily apparent that without departing from the spirit and scope of the present invention, various repair can be carried out to the embodiment of the present invention
Change and changes.Therefore, the invention is intended to cover fall within the scope of the present invention as defined by the appended claims all to repair
Change or modification.