D
@Alex Papadimoulis said:@DZ-Jay said:Although I
admit that most of the texts that need transforming are only within the
1k to 5k size range, I believe there are enough hits to the server to
bring performance down -- particularly when the server is handling 6
websites all running the same code, and all handling roughly the same
amount of hits.
Understandable ... so we're back to the original problem. Let's see,
if I absolutely had to do this in VBScript ... given these assumptions:
(1) Templates are infrequently updated, (2) On average, templates have
more than 3 tags needing replacement, (3) Replacement is page-view
specific (order number, total, etc) ... I'd say cache the templates and
the indexes to the tags.
One way you could do it is with a Scripting Dictionary at the
application scope ... but now that I think about it, that probably
won't work because SD is probably apartment threaded. I'd say go with a
FreeThreadedXMLDOM to store your templates and indexes. From there, you
can easily retreive them and do your replacements much quicker.
Yes, the SD is apartment threaded (I learned this the hard way,
since using it in application scope was another bonehead idea of one of
the consultants. -- "But I don't understand what happened! It worked
fine on my computer. Why, yes, I was testing it by myself, why do you
ask?" :) However, I have installed a third-party replacement
which does not have threading issues. So loading up commonly used
things in application scope using a dictionary is an option.
But let me explain the nature of the templates. In the
e-commerce site, they are snippets of text containing product
descriptions. Each one is saved in a separate file. So,
(1) True - templates are infrequently updated
(2) True - on average, templates have about 5 tags that need replacement
(3) False - replacement is not page-view specific. The
replacement is just simple macro expansion of company policies or
additional info related to a particular product. In any case,
they are self contained (i.e. the macros contain all the information
needed for their expansion.) Here's an example:
@@ITEM_LINK:1234@@
Will expand to an <A HREF> hyperlink linking to the product page of item #1234.
The one potential problem I see of pre-loading the templates into
memory -- if that was what you were suggesting -- is that each site has
on average 5k product files, of an average 4kb in size; and there are 6
sites, all running on the same server. (Forgetting for a moment all the
possible memory leaks and the obscene memory/CPU consumption of the
entire codebase monster, this is still pretty big, no?)
But I think we are getting out of the scope of our original
discussion. I didn't set out to try to solve the site's
problems. I was just curious to see if anybody had an alternative
to multiple Replace() calls, since all were so quick to say how "wrong"
it was in previous WTF posts. I appreciate that you are taking
the time to discuss this with me, and it has been very interesting, but
I really do not think it would be wise to add another layer of
complexity to the code, if the performance benefit is not going to be
substantial. (I fear finding my own code posted out of context in
this site when I leave this place He he he :)
Thanks,
dZ.