具有并行非阻塞数据库访问的 Web 脚本语言?
我的 web 应用程序需要使用多个数据库分片,并且偶尔需要并行查询这些分片。 是否有任何 Web 脚本语言能够成熟、稳定地支持并行非阻塞数据库访问? 如果是这样,你能指出我正确的方向吗? 免费的开源是首选,但我最想要的是有用的东西。
线程对我来说很好,但我不需要真正的多线程支持。 我想要的只是对五个不同的数据库服务器进行五个 10 秒的数据库查询,花费 10 秒而不是 50 秒。对我来说,它实际使用了多少个 CPU 并不重要。
My webapp will need to use multiple database shards, and occasionally need to query these shards in parallel. Are there any web scripting languages that have mature, stable support for parallel non blocking database access? If so, can you point me in the right direction? Free open source is preferred, but I mostly want something that will work.
Threads are fine with me, but I don't require real multi-threading support. All I want is for five 10-second database queries to five different database servers to take 10 seconds and not 50. It doesn't matter to me how many CPUs it actually used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您似乎并不需要并行非阻塞 I/O,而是需要并行非阻塞数据库访问,这通常是通过不同的 API 处理的。
例如,在 Java 中,一般 I/O 是通过 java.io 和 java.net 中的组件处理的,但数据库访问是通过 java.sql 和特定于供应商的驱动程序处理的。 类似的特征是其他平台/语言的典型特征。
看来您的主要问题是实现某种多处理/多线程,您可以从中发出单独的并行数据库访问请求。 我建议这是你应该研究的主要领域。
关于该主题有很多可用的材料,但您需要关注您的特定平台/语言以了解大部分细节。 请注意,这传统上是软件开发中非常困难的领域。
最美好的祝愿给你...
Actually, it does not appear that you need parallel non-blocking I/O--you need parallel non-blocking database access, which is typically handled through a different API.
For example, in Java, general I/O is handled through components in java.io and java.net, but database access is handled through java.sql and vendor-specific drivers. Similar characteristics are typical of other platforms/languages.
It would seem that your main issue would then be to implement some kind of multiprocessing/multithreading from which you could make the separate, parallel database access requests. I suggest that is the main area that you should research.
There is a lot of material available on that topic, but you will need to focus on your particular platform/language for much of the detail. Please note that this is traditionally a VERY difficult area of software development.
Best wishes to you...
一种可能的解决方法是划分网页,使每个部分仅命中一个分片。 浏览器应该为每个部分启动单独的 AJAX 请求并在客户端构建页面。
此解决方案不依赖于所选的语言/框架,但需要在客户端启用 JavaScript。
性能可能会有所不同,具体取决于每个访问者的操作系统、浏览器和设置 (更多信息)。 但是,一旦页面每个部分的数据可用,页面就会增量呈现。
与服务器端解决方案相比,这种方法的缺点是将复杂性从服务器转移到客户端 JavaScript,并增加了 Web 服务器的负载。
A possible work-around is to divide the web page so that each part only hits one shard. The browser should launch a separate AJAX request for each part and construct the page client-side.
This solution wouldn't depend on the chosen language/framework, but requires enabling JavaScript on the client side.
The performance might vary depending on each visitor's OS, browser and settings (more info). However, the page would render incrementally as soon as data from each part of the page comes available.
As drawbacks compared to the server-side solution, this method moves complexity from the server to client-side JavaScript and increases the load on the web server.