Forum > Networking and Web Programming
Running database access as Windows service
egsuh:
I have written a web server, which is CGI way, and it accesses database (firebird).
As you know, this approach has to connect to database at every request.
In most cases, this does not cause any problem. But when there were many requests, I found the database operation is too slow.
So I'm thinking of a daemon program that stays in memory and runs functions/procedures called from web module. This will be running as a service on Windows.
Do you think this is feasible? Web module will call the daemon/service module, and passes and receives data from it. What kind of data are transferrable? Only integer, string, etc., or any streams?
rvk:
--- Quote from: egsuh on May 28, 2024, 10:54:44 am ---What kind of data are transferrable? Only integer, string, etc., or any streams?
--- End quote ---
Isn't that something only you can answer :P
First I would investigate why lots of connection cause a slowdown (there could be other reasons).
But if you really want to go the daemon way... you might consider json as inbetween format. But that also kinda depends on what you are transferring in cgi to your client. What format do you use there?
egsuh:
--- Quote ---First I would investigate why lots of connection cause a slowdown (there could be other reasons).
--- End quote ---
You'll know that connecting to DB would take rather long time. So if many web-requests come in in a short period of time, database is slowed down or get stuck, as every request will try to make a connection. Currently I think this is the most serious cause of slow down.
--- Quote ---But if you really want to go the daemon way... you might consider json as inbetween format. But that also kinda depends on what you are transferring in cgi to your client. What format do you use there?
--- End quote ---
Well... if I can pass string type, whether in JSON type or other format, it would suffice I guess. Simply I'm wondering whether it is possible to pass TStream as parameter. If TStream is passable then practically I can pass any object.
egsuh:
BTW, other operations should be done anyway once. But connection, which may stay connected after the first connection, has to repeat disconnection and reconnection, which is absolutely unnecessary.
Thaddy:
CGI is not suitable for many connections. FastCGI performs better. Reason:
CGI has an instance per connection. FastCGI not. But it also depends on your server.
So your problem is not the number of connections, but the availability of resources (memory and cores). That won't change with a service or daemon.
See: https://en.wikipedia.org/wiki/Common_Gateway_Interface
Navigation
[0] Message Index
[#] Next page