[NCLUG] programming question

Gary Rogers garyr at dmin.net
Sun Jul 1 08:08:03 MDT 2001


Well, I'll say this from a person who's had to run hurd on web programmers,
find bottle necks and make them believe that it's their code...

When dealing with the web remember that most of the languages/application
servers out there are interpereted languages, then have to be compiled at
runtime everytime you take a page hit. It doesn't matter too much if you've
got a very clean oo program, or a scruffy perl nugget, it's still going to
spike your processor on a page hit. You can get away from this by using java
servlets, or compiled c. Of course then the servlet engine introduces
overhead ;)

If you have a set standard to develop and write to, that's probably more
important than the speed and effiency of your code. An ounce of
maintainability is worth more than a pound of 'OO'. If you code is
maintainable by someone else written in 'oo' cool, if it leaves your
replacement scratching their heads, it's not worth beans.

In my experience writing CGI's and system support scripts copious
documentation and well-thoughtout procedureized code is where you want to
go. Breaking everything out into multiple subs/functions/procedures that
each do a small manageable bit of work is best for maintainability and
code-reuse, it's 'oo' like without having to fully implement objects and
inheritance and such. Now that said I understand that there are places for
objects and 'oo', but you've got to ask yourself, in my current coding team,
or the person that tinkers with thise code after I've moved on (and believe
me the smallest little thing could be used again) will they understand my
code and be able to easily modify it? If you can answer yes then your code
is efficient.

As for Keynote, don't diss the 'Note! They've saved my bacon more than once
when I could go to the programmers and say 'see your page is taking 3
seconds to load.' and go to the security guy and say 'see your firewall is
causing initial connections to take 3 seconds'.

g:wq

----- Original Message -----
From: "mike cullerton" <michaelc at cullerton.com>
To: <nclug at nclug.org>
Sent: Saturday, June 30, 2001 5:11 PM
Subject: Re: [NCLUG] programming question


> on 6/30/01 4:30 PM, Gary Rogers at garyr at dmin.net wrote:
>
> > Are you sure that your time is spent in the application? Here's what I'm
>
> this is a theoretical question. i'm wondering, is there a difference, in
> general, programmatically speaking, between having one large object, two
> disjoint objects or an object that extends another object.
>
> > getting at: With a web page there are many variables that go into to
> > download speed. Identifying where the slow down is is part of tuning the
> > pages for maximum speed. In your case I'd say you're probably right, it
will
> > be a SQL issue. However, you may be seeing DNS lookups taking time, or
> > initial download, especially if you're behind a firewall that supports
> > Stateful packet inspection.
>
> i didn't mean to suggest there was a current problem. the code wasn't even
> written when i asked the question. (it is currently written as two
disjoint
> classes)
>
> there is no current problem. the sql issue was just something i learned
from
> a previous project. mentioning it probably confused the situation. sorry.
> currently, everything (already written) works fine. it's all contained on
> one ethernet, running on an underused server, with local dns. rather than
> trying to solve a particular problem, i'm trying to learn about oop
> programming in general.
>
> >
> > The best page download timer that I've used was with Keynote systems,
but
> > that's probably not an option. Find a page timer that splites things
down
> > into DNS lookup, initial TCP connection, Page download. Then you're sure
> > that your page is the bottle neck.
>
> Keynote, huh?! that's starting a holy war :)
>
> >
> > Beyond that I'm not sure what tools MySQL gives you to time queries.
I've
> > worked with Oracle DBA's that could find out how long my quesies were
> > taking. Also, WebLogic was good about telling my how long pages were
> > connected to the database. Can PHP time your queries for you? The
question
> > you're looking to answer here is this: Are my queries taking long
because of
> > the Database, or because of some code manipulation I'm doing with the
> > returned code? I want to say that as much code manipulation you can do
> > inside the database the better, but that's only because I'm used to
beefy
> > database machines that handle cpu intensive joins better than ripping
> > returned data with perl on the Webservers, or in your case PHP.
>
> again, there is no current problem. as i mentioned in my first post, the
sql
> issue was solved by adding an additional index to a table defintion.
>
> as for php timing queries, one could always check the time before issuing
a
> query and again when a result is received, and then comparing the times.
if
> using the PEAR DB modules, the result handler contains all the result info
i
> believe.
>
> if i do end up having a bottleneck somewhere, i'm betting on the fact that
> the server is an old dual pentium 166 :)
>
> >
> > Anyway, just don't assume that it's your code is all I'm saying. You may
> > have to transfer where you're doing the work to get better performance
from
> > a web application.
>
> the question only applies to the code. 'other things equal' so to speak
>
> thanks,
> mike
>
> >
> > Gary Rogers
> > (former) Web SysAdmin ;)
> >
> > ----- Original Message -----
> > From: "Evelyn Mitchell" <efm at tummy.com>
> > To: <nclug at nclug.org>
> > Sent: Saturday, June 30, 2001 3:08 PM
> > Subject: Re: [NCLUG] programming question
> >
> >
> >> On Sat, Jun 30, 2001 at 01:40:15PM -0600, mike cullerton wrote:
> >>>> It helps to understand what resources you're trying to conserve.
> >>>
> >>> i hadn't really thought about it specifically, but now that you ask,
i'd
> > say
> >>> processing or maybe even latency. this is a web based program written
in
> >>> php. in an earlier prototype of this app, i had one page that took a
> > long
> >>> time to load. that turned out to be a mysql problem. i fixed it by
> > adding a
> >>> new index.
> >>>
> >>> so, would any particular approach add an extra amount of processing or
> >>> latency?
> >>
> >> The only way to discover that is to profile the three different
> >> approaches and see which one takes more processing or have higher
latency.
> >>
> >> Evelyn
> >>
> >> _______________________________________________
> >> NCLUG mailing list
> >> NCLUG at nclug.org
> >> http://www.nclug.org/mailman/listinfo/nclug
> >>
> >
> > _______________________________________________
> > NCLUG mailing list
> > NCLUG at nclug.org
> > http://www.nclug.org/mailman/listinfo/nclug
> >
>
>
>  -- mike cullerton
>
>
> _______________________________________________
> NCLUG mailing list
> NCLUG at nclug.org
> http://www.nclug.org/mailman/listinfo/nclug
>




More information about the NCLUG mailing list