From owner-freebsd-questions@FreeBSD.ORG Wed Apr 26 17:08:33 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 39A5C16A40F for ; Wed, 26 Apr 2006 17:08:33 +0000 (UTC) (envelope-from freebsd@anjos.strangled.net) Received: from mail.anjos.strangled.net (87-196-141-176.net.novis.pt [87.196.141.176]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3905C43D5D for ; Wed, 26 Apr 2006 17:08:30 +0000 (GMT) (envelope-from freebsd@anjos.strangled.net) Received: from compaq.anjos.strangled.net (localhost [127.0.0.1]) by mail.anjos.strangled.net (8.13.4/8.13.4) with ESMTP id k3QH8SMJ004264; Wed, 26 Apr 2006 18:08:29 +0100 (WEST) (envelope-from freebsd@anjos.strangled.net) Received: (from miguel@localhost) by compaq.anjos.strangled.net (8.13.4/8.13.4/Submit) id k3QH8RxZ004263; Wed, 26 Apr 2006 18:08:27 +0100 (WEST) (envelope-from freebsd@anjos.strangled.net) From: Miguel Ramos To: Pgold In-Reply-To: <96341e070604260807p5996d2f0n2b7d9ce818e8bf3d@mail.gmail.com> References: <96341e070604260807p5996d2f0n2b7d9ce818e8bf3d@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: Wed, 26 Apr 2006 18:08:26 +0100 Message-Id: <1146071306.4088.15.camel@compaq.anjos.strangled.net> Mime-Version: 1.0 X-Mailer: Evolution 2.4.2.1 FreeBSD GNOME Team Port Cc: freebsd-questions@freebsd.org Subject: Re: CGI "service". X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Apr 2006 17:08:33 -0000 Qua, 2006-04-26 =E0s 12:07 -0300, Pgold escreveu: > Hi, I=B4m developing a web app in C++. But it loads a huge amount of > from a Database to memory, and I can=B4t afford doing this everytime > someone asks for the page. Is there a way to make the program to keep > running, and reading requests made via CGI? > If it helps, i=B4m running FreeBSD 6.0 with Apache 2.2. >=20 > Greets, > Pedro. If the problem is keeping the data in memory, I don't think even mod_perl or mod_python will help you. Sugestion #1 - write an apache module; that will be always in memory. I'm not sure if it will be hard to compile. Sugestion #2 - forget about C++ and use mod_mysql or whatever is available for your DBMS. Sugestion #3 - split your web app in two parts: cgi scripts (or apache module) and a server app that keeps data in memory and responds to requests made by cgi scripts. Communication between the two can be made with pipes, sockets, shared memory or whatever you like. Sugestion #4 - load less data from the database; only that which you need to generate output. (For example, for an SQL database, use WITH, HAVING, OFFSET and LIMIT wisely). Any more sugestions? -- Miguel