WebQueryOpen or not WebQueryOpen?
Especially Jake Howlett is very enthousiastic about WebQueryOpen agents. I agree they offer a lot of unique solutions for difficult problems. But are they fast enough? Let's find out.
The test
I have my WebQueryOpen-free homepage. It is built with an embedded view for the most recent posts. For the side blocks, I use @DbLookups. A few reloads in FireBug gives me load times between 15ms and 31ms, for the HTML only. Note that I live in Belgium, and the server is on the same backbone, so the HTTP request does not have to swim across oceans.
Then I made a WebQueryOpen to replace the embedded view with its LotusScript equivalent. I used the same techniques as in a previous post. I collect the HTML entries in a stringbuffer class and put all of it in a text field at the end of my agent. I also have the HTML for each entry prepared in a computed field, so I can take it right out of the ViewEntry:
Sub Initialize
On Error Goto catch
Dim ns As New NotesSession
Dim doc As NotesDocument
Dim db As NotesDatabase
Dim view As notesView
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim out As New StringBuffer(100)
Dim debug As New StringBuffer(100)
Dim i As Long
Set doc=ns.DocumentContext
debug.add "Agent started."
DbPath=doc.GetItemValue("DbPath")(0)
debug.add "DbPath: " + DbPath
Set db=ns.CurrentDatabase
Set view=db.GetView("vLaunch")
Set vc = view.AllEntries
out.add "<h1>Homepage - Most recent posts</h1>"
out.add |<div id="viewbody">|
For i=1 To 7
Set entry=vc.GetNthEntry(i)
If Not entry Is Nothing Then
out.add entry.ColumnValues(1)
End If
Next
out.add("</div>")
Goto finally
catch:
debug.add "Error " & Err & " in line " & Erl & ": " & Error$
out.add "Error " & Err & " in line " & Erl & ": " & Error$
Resume finally
finally:
debug.add "<br />Agent finished."
doc.replaceitemvalue "HtmlBody", out.collapse("")
'doc.replaceitemvalue "DebugOut", debug.collapse("<br />")
End Sub
The result
You can test the page with the WebQueryOpen. Surprisingly, I get exactly the same load times as the page with the embedded view: between 15ms and 31ms. There is no trace whatsoever of any delay caused by the agent.
Although my test is but an indication and no real scientific proof, I think we can safely start using WebQueryOpen agents, providing we optimize the agents themselves for performance. It is clear that you don't want to do lots of time-consuming processing in there. I found a good reading start on performance tips on www.nsftools.com.
The next test will be more daring: what would the impact be if I render the complete HTML page from the WebQueryOpen agent?
Comments
14/08/2007 22:37:45, Theo Heselmans
I have build some serious websites for doing Surveys. Every page was build during webqueryopen, with complex and long html-assembling: works like a charm !
14/08/2007 22:53:07, Michel Van der Meiren
Hey Theo. We should have a drink together one of these days. I've done my share of surveys too, both for my own company (GFI-EMD) as for my customer (Toyota). I didn't find the time yet to show my way of building survey applications in Domino. Still to come :-)
15/08/2007 08:53:18, Patrick Kwinten
At least one plus I see directly is YOU control what is being spitted out and NOT Domino.
16/08/2007 05:15:52, Stephan H. Wissel
The main reason why I don't like WQO agents is their potential for abuse (I worked too much with corporate developers). Jake's stuff and your examples are on the other hand quite cool. The big question: Do the load times change when you put load onto the server. What would happen if 100 or 1000 request trigger the WQO agent within a few seconds. Some action with JMeter or Grinder required?
17/08/2007 07:08:04, Stephan H. Wissel
Michel, can u contact me, I have the stress-test script for you. I don't want to run it against your server without your consent. :-) stw
17/08/2007 10:34:54, Michel Van der Meiren
@Stephan: yes, better do it on a test server, because this blog is on the hosting server of my company. Thanks.
To add a comment, log in or register as new user. It's free and safe.