简体   繁体   中英

how to share a common data structure in high performance java web service applications

I am developing a couple of web services - one to BUY a product and another to VALIDATE a product. Multiple clients will be calling the BUY (around 250/sec) and same for VALIDATE. They need to query and update a tabular data structure before calling the backend.

I have a feeling that using a relational database table like Oracle to maintain this common data structure will slow down things because of network latency (assuming database and queries are tuned optimally). I have been proposed EhCache and Hazelcast but I prefer using a database table because I know it better.

Can anyone confirm if hitting a database across a network could prove to be a bottleneck for an application that's supposed to serve 250-300 transactions per second?

Certainly we are okay if the server instance goes down and we lose the in-memory representation of the data structure.

That really depends what your application is doing.
Of course you can use a database machine with expensive hardware, and expensive network hardware.
The question is - is this really needed?
As stated in some of the comments - Caching will mostly help you in case that you perform mostly READ (more READ requests than write requests). In order to optimize you should consider indexing (for example - if you store addressed, you can consider indexing by an "ip" field, assuming that most queries that are not by ID are by this field) ,
which is just one part of correct DB schema planning (other aspects of this may be to avoid complex joins between tables, by modelling your data properly as much as possible), and maybe even a NoSQL database.
What about scaling You should use a distributed cache/distibuted data structure if you go for caching and scaling.
For example, infinispan can help here.
You can also improve performance by using in memory/in process (ie - its code is in a jar and is co-hosted on the JVM of the application) such as h2 - this can further reduce querying time. But once again, it really depends on your specific use cases, what you described is unfortunately too general.

IMO,只要更新请求低于查询请求,缓存就会有所帮助...想象一下,您缓存为一个大地图,如果您每次更新服务器上的行也都需要更新,则将存储已经查询的值,并且更新通过使缓存条目无效来再次执行对DB的请求。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM