【问题标题】:F5 iRule for UIE - latency on using the persist uie commandF5 iRule for UIE - 使用 persist uie 命令的延迟
【发布时间】:2016-10-18 14:35:26
【问题描述】:

我们正在尝试向我们的服务引入 F5 负载均衡器,为此,我们正在开发一个 iRule,它使用通用持久性功能来持久化会话。
但是当尝试使用 iRule 命令“persist uie”保持会话时,我们遇到了延迟。
延迟可能超过 1000 毫秒...
似乎是什么问题?我们怎样才能摆脱这种延迟?

请查看我们的 iRule 代码和我们记录的日志。
提前致谢

这是我们的 iRule 代码:

when HTTP_REQUEST {
                if {[HTTP::host] equals "mpi-lb.creditguard.co.il" } {
                                set txID1 ""
                                set txID2 ""
                                set txID3 ""
                                set txID4 ""
                                set txID5 ""
                                set txID6 ""
                                set txID7 ""
                                set txID8 ""
                                # Log details for the request
                                regexp {(txId|token|mpiTransactionId|transactionID)[=>]([0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12})([&< ]|$)} [HTTP::uri] => txID1 txID2 txID3 txID4
                                regexp {(txId|token|mpiTransactionId|transactionID)[=>]([0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12})([&< ]|$)} [HTTP::payload] => txID5 txID6 txID7 txID8
                                log local0. "uri:[HTTP::uri]:payload: txID2:$txID2 txID6:$txID6"
                                if {$txID2 != ""} {
                                                log local0. "persist lookup uie:[persist lookup uie $txID2] $txID2 in uri"
                                                persist uie $txID2
                                } elseif {$txID6 != ""} {
                                                log local0. "persist lookup uie:[persist lookup uie $txID6] $txID6 in paylod"
                                                persist uie $txID6
                                }
                }
}

when HTTP_RESPONSE {
                if {([IP::server_addr] equals "172.16.100.16") || ([IP::server_addr] equals "172.16.100.17") } {
                                # Trigger collection for up to 1MB of data
                                if {[HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] <= 1048576} {
                                                set content_length [HTTP::header "Content-Length"]
                                } else {
                                                set content_length 1048576
                                }
                                # Check if $content_length is not set to 0
                                if { ([HTTP::status] == 200) && ($content_length > 0)} {
                                                HTTP::collect $content_length
                                }
                }
}

when HTTP_RESPONSE_DATA {
                if {([IP::server_addr] equals "172.16.100.16") || ([IP::server_addr] equals "172.16.100.17") } {
                                # do stuff with the payload
                                #find the application unique identifier between <uid> and </uid> (5 is the length of <uid> string)
                                set txId [string trim [findstr [HTTP::payload] "<txId>" 5 "</txId>"] ">"]
                                if {$txId != ""} {
                                                log local0. "[IP::server_addr] : persist add uie #$txId#"
                                                persist add uie $txId 1800
                                }
                }
}

这里是日志(您可以看到 14:16:08 和 14:17:08 之间的延迟)

Tue Jun 14 14:16:03 IDT 2016  info  cgwaf tmm3[10326]    Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/CreateTransactionExtended:payload: txID2: txID6:  
Tue Jun 14 14:16:04 IDT 2016 info cgwaf  tmm3[10326]     Rule /Common/mpi-lb-irule <HTTP_RESPONSE_DATA>: 172.16.100.16 : persist add uie #03f72209-754e-4bde-85f6-69cdf4d27526#  
Tue Jun 14 14:16:08 IDT 2016  info cgwaf tmm1[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/PerformTransaction? txId=03f72209-754e-4bde-85f6-69cdf4d27526:payload: txID2:03f72209-754e-4bde-85f6-69cdf4d27526 txID6:  
Tue Jun 14 14:16:08 IDT 2016  info cgwaf tmm1[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: persist lookup uie:/Common/mpi-lb 172.16.100.16 443 03f72209-754e-4bde-85f6-69cdf4d27526 in uri 
Tue Jun 14 14:17:08 IDT 2016  info cgwaf tmm2[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/merchantPages/ResponsiveWebSources/images/cvv.jpg:payload: txID2: txID6:  
Tue Jun 14 14:17:08 IDT 2016  info  cgwaf tmm[10326]    Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/merchantPages/ResponsiveWebSources/images/mastercard_slice.gif:payload: txID2: txID6:  
Tue Jun 14 14:17:08 IDT 2016  info cgwaf tmm[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/merchantPages/ResponsiveWebSources/images/pci_slice.gif:payload: txID2: txID6:  
Tue Jun 14 14:17:08 IDT 2016  info cgwaf tmm[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/merchantPages/ResponsiveWebSources/images/visa_slice.gif:payload: txID2: txID6:  
Tue Jun 14 14:17:08 IDT 2016  info cgwaf tmm[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/merchantPages/ResponsiveWebSources/images/Logo.gif:payload: txID2: txID6:  
Tue Jun 14 14:17:08 IDT 2016  info  cgwaf tmm3[10326]    Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/merchantPages/ResponsiveWebSources/images/qm.png:payload: txID2: txID6:  
Tue Jun 14 14:18:06 IDT 2016  info  cgwaf tmm2[10326]    Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri://CGMPI_Server/ProcessCreditCard:payload: txID2: txID6:03f72209-754e-4bde-85f6-69cdf4d27526  
Tue Jun 14 14:18:06 IDT 2016  info cgwaf tmm2[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: persist lookup uie:/Common/mpi-lb 172.16.100.16 443 03f72209-754e-4bde-85f6-69cdf4d27526 in paylod  
Tue Jun 14 14:18:07 IDT 2016  info cgwaf tmm2[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri:/CGMPI_Server/merchantPages/nlb/OK.jsp?uniqueID=697536646.622257&lang=EN&authNumber=9125242& responseMac=7e77d7fe857e707ddf1c8990c80da8373f716c79d0ee79b88 f3d898a9ff0afc0&cardToken=1051484189394580& cardExp=0217&personalId=88888888& cardMask=458045******4580& txId=03f72209-754e-4bde-85f6-69cdf4d27526& numberOfPayments=&firstPayment=&periodicalPayment=:payload: txID2:03f72209-754e-4bde-85f6-69cdf4d27526 txID6:  
Tue Jun 14 14:18:07 IDT 2016  info cgwaf tmm2[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: persist lookup uie:/Common/mpi-lb 172.16.100.16 443 03f72209-754e-4bde-85f6-69cdf4d27526 in uri 
Tue Jun 14 14:18:07 IDT 2016  info cgwaf tmm2[10326]     Rule /Common/mpi-lb-irule <HTTP_REQUEST>: uri:/CGMPI_Server/merchantPages/WebSources/images/ssl.png:payload: txID2: txID6:  

【问题讨论】:

    标签: latency f5 big-ip


    【解决方案1】:

    我看到您在入站和出站流上使用正则表达式查找,这些非常昂贵且耗时。请记住,F5 需要代理数据、保存数据、提取流、执行正则表达式操作,然后将其传递回出口堆栈。如果您想优化时间,请尝试另一种方式来持久化数据流。

    也就是说,您可以使用计时命令查看 iRule 使用的每个事件处理周期: https://devcentral.f5.com/wiki/iRules.timing.ashx

    根据您运行的 TMSH 版本,您应该在 GUI 中或通过 TMSH 命令获得统计信息。

    【讨论】:

    • 感谢@kruczkowski 的快速回答,我们将使用计时命令。我们也知道正则表达式,我们计划将“txId”移动到标题中。但如果我没记错的话,我们在 regexp 命令完成后遇到了延迟,更准确地说,在执行“persist uie”命令时正在查看延迟。这有意义吗...?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-28
    相关资源
    最近更新 更多