On May 12, 2013, at 11:15 PM, Karthik Sharma wrote: > I have a function called act_like_switch which uses a databased backed > architecture.If I come across a packet whose source address is not in the > database I insert the <src_packet,port_no> into the database.Then I do a > query of the destination address in the database and retrive the port_no from > the database and then send out the packet. > > As you can see in the code below I measure the time taken for insert and > query.I also record the counts as well.Apparently the average number of > inserts is 30 per seconds and the average number of queries is 700 per > seconds.This is very low for my application.Are there any ways to improve > this numbers? Am I doing anything wrong?
This doesn't seem totally outlandish to me. That's like 33ms per write... databases incur a penalty for their consistency properties and so on. I don't know why you're doing this, so it's hard to evaluate your design. I'd suggest you ask yourself a bunch of questions... Do you need to write this stuff to a database? Do you need to do it this often (could you store this in a Python data structure temporarily and write it to the database every few seconds)? Do you need to do it for every exact-match flow (or could you do it for broader entries like, for example, l2_pairs does)? Good luck. -- Murphy
