Forum Discussion

Chen_yongjian_1's avatar
Chen_yongjian_1
Icon for Nimbostratus rankNimbostratus
Jun 08, 2005

How to loadblance Oracle DB by use irules to differentiate read and write request?

I want to use irules to differentiate oracle read and write request.

 

Who can tell me how to do it?

 

 

rule:

 

If request include "read ABC",then use db_read_pool

 

else if request include "write string" then use db_write_pool

 

 

I can not know what is the right syntax.pls help me,thanks.

 

 

  • Assuming that the read/write requests are over TCP, you could use something like the following

     when CLIENT_ACCEPTED { 
       TCP::collect 100 
     } 
      
     when CLIENT_DATA { 
       if { [TCP::payload] contains "read ABC" } { 
         pool db_read_pool 
       } elseif { [TCP::payload] contains "write string" } { 
         pool db_write_pool 
       } 
     }

    This is a standard TCP based iRule where you request 100 bytes after the client connection is accepted. Then, when that data comes in you can check the payload for your matching strings. This assumes that the "read ABC" or "write string" are in the first 100 bytes. You'll have to bump this number up if the string you are looking for is further into the payload than that.

    Also, if the payload is binary, you'll have to use the binary scan command documented at http://tmml.sourceforge.net/doc/tcl/binary.html (Click here) to find the string.

    -Joe