drzb7969753 2012-10-18 20:33
浏览 70

Web应用程序的超快数据库访问 - SQL或NoSQL,解释PHP还是编译C? [关闭]

I'm currently building a web application that needs to access a (really) big database of strings and compare them to a given 'request string' - This has to be done over and over again using different comparison methods (number of identical words, order of words...) and should be scalable and, more important, fast.

I thought about about implementing the comparison method itself in C, because it's obviously much faster than interpreted, though more 'webby' languages like PHP. This brought me to three questions:

1) How am I supposed to 'connect' the C application to the web server (currently Apache)? I thought about the usual CGI-way, but because of its need to create one new process per request it would be less scalable and fast - at least that's what I read about it.

2) Which database technology is best to use with C for this use-case?

3) Last but not least, do you think it's worth the struggle or would it be enough to go the usual way by building a PHP-Script that connects to a MySQL database - how big is the speed difference?

Thanks in advance, David

  • 写回答

2条回答 默认 最新

  • dri98076 2012-10-18 20:41
    关注

    Apache-2.4.x has mod_dbd, which can talk to various database back-ends (using precompiled queries for speed) straight out of Apache config-files. This can be used in, for example, mod_rewrite's rules to alter incoming requests depending on results of the queries.

    In other words, depending on the details of your application, you may be able to avoid coding altogether.

    If you do have to write code, however, I'd suggest you first implement the prototype in a language you know best. There is a good chance, it will be "fast enough" -- or that the bulk of the time spent per request will be on the database side making the choice of the language irrelevant.

    Connecting to a database back-end from C is easy -- each database vendor has (at least one) client-library implementation for C-programs.

    If your app does not require multiple HTTP-servers to talk to the same (single) database, then your best DB would be a local one: SleepyCat's (now Oracle's) "db", gdbm, or SQLite3.

    Also, if the updates (changes to the database) are infrequent, you can use flat-files and build the database in memory... This will limit the database's maximum size, but will be the fastest and allow you avoid handling (re)connections, etc.

    EDIT: memcache is an external database -- whether it is running on the same system or a remote one, you have to connect to it, talk to it, and copy data from its memory into yours. If database-changes aren't frequent, you are better off keeping stuff in your own memory and using it straight from there.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答