How to divert rest api calls from external applications to a particular node

Jonnada Kiran
Contributor
February 2, 2018

We have a 4 node cluster for JIRA. We are using F5 load balancer to distribute traffic. Due to increase in rest api calls from external applications we are experiencing some performance issues. So, we want divert rest api calls from external applications to Node 4. I read this https://confluence.atlassian.com/enterprise/traffic-distribution-with-atlassian-data-center-895912660.html. But, not sure how to implement in our F5 load balancer. Can someone please give some detailed steps to implement this? Thank You.

2 answers

0 votes
Sanu Soman February 14, 2018

Hi Jonnada,

Did you made it worked? I am also trying to setup same with F5 load balncer.

Please share the details if you done so?

Thanks,

Sanu P Soman

Jonnada Kiran
Contributor
February 14, 2018

@Sanu Soman Hi. I have implemented it. It works great. Implement the below irule in F5. Thanks.

 

when HTTP_REQUEST {

log local0. "New code"
set referrer_host [ URI::host [HTTP::header value Referer]]
log local0. "host: [HTTP::host]"
log local0. "uri: [HTTP::uri]"
log local0. "path: [HTTP::path]"
log local0. "Referer: $referrer_host"


if { ([HTTP::header exists "Referer"]) } {

if { $referrer_host eq "" } {
set referrer_host "none"
}

if { !($referrer_host contains "jiratest.corp.chartercom.com") } {

log local0. "referrer is not equal to jira"
if { ([HTTP::uri] contains "/rest/") } {
log local0. "referrer is not equal to jira and contain rest"
pool JIRA-test-external-pool
} else {
pool JIRA-test-pool
}

} else {
log local0. "referer is jira"
pool JIRA-test-pool
}

} else {
log local0. "Referer does not exist"

if { !([HTTP::uri] contains "/rest/") } {
log local0. "referrer is not equal to jira and contain rest"
pool JIRA-test-pool
} else {
pool JIRA-test-external-pool
}
}


}
Sanu Soman February 14, 2018

Great and many thanks for sharing it.

Is your JIRA running with SSL enabled? If so, do we need to terminate SSL at F5 level to configure this?

Jonnada Kiran
Contributor
February 14, 2018

I dont know about SSL.

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 15, 2018

Dear @Jonnada Kiran,

you have to terminate SSL on F5 otherwise you cannot filter, because the path information will be encrypted.

So long

Thomas

Sachin July 11, 2018

Hi Thomas,

We have the same requirement where we want to redirect external Rest API only to specific node we have 4 node and we want to redirect external REST traffic to node 4.

We have written iRule for that but we observed few thing

1. Jira becomes slow.

2. Xray plugin is not working as expected like "Test" tab is not appear on the screen.

Sachin July 11, 2018

Thomas,

what do you mean "terminate the SSL on F5"? because we have SSL implemented on F5.

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2018

Dear @Sachin,

as I wrote, if you will try to load balance HTTP traffic depending on the path information of the URL, it may not be encrypted.

This slow Jira will result (I guess) from Jira's own communication over the REST API. Best do not balance this to only one node.

For the XRay Plugin, best ask the vendor. They should know about their plugin engine.

So long

Thomas

Orit Nachshon
Contributor
July 12, 2018

Hi Thomas,

Thanks for reply.

So what you r saying is we should not redirect REST API call to specific one node if we have SSL on F5?

And if we want to redirect then we have to skip ssl?

 

Thanks,

Sachin

Jonnada Kiran
Contributor
July 12, 2018

@Thomas Deiler@Sachin@Sanu Soman Sorry for replying late. Redirecting traffic to a node raised indexing problems between nodes. 

Orit Nachshon
Contributor
July 12, 2018

@Jonnada Kiran:  Did you experience this? Did Atlassian confirm about this? what is solution for this then?

Jonnada Kiran
Contributor
July 12, 2018

Arlassian recommended not to divert rest calls till they find a solution 

Orit Nachshon
Contributor
July 12, 2018

@Jonnada Kiran Thanks for reply. Does they have created bug or any issue for their developer for this?

Andriy Yakovlev _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2018

Hi all, 

I see that this is some confusion around LoadBalancing, so to prevent the uncertainty please let me clarify some points. :)  

  • To do session affinity at Loadbalancer and redirect traffic based on URL path (/REST), you would need to see request plain text, so as Thomas mentioned you need to terminate SSL on F5 (do SSL offloading). This is just a technical requirement. 
  • This is very crucial to make sure that you redirect traffic only from External application (bot), not from the normal user. In another case, you will be break session affinity which leads to different functional and performance problems. 
  •  Regarding Redirecting traffic to a node raised indexing problems between nodes. It's hard to comment without context, but in general, redirecting some traffic to the separate node does differ from any other normal setup. We have many clients running this without any problems.
    • Speculating here: if dedicated node would receive too many changes, those changes would need to be propagated to other nodes (load is skewed) and in case cluster doesn't have enough capacity that would case indexing delays. That being said, this is not specific to Redirecting traffic to a node but like a genetic balancing load problem. 

 

How you can check that session affinity is fine. 

  • Check reply headers from Jira and find x-anodeid, eg:
x-anodeid: i-02b2b80fafcf9ad1d
  • make sure it's the same for all requests 

 

Hope this helps

Cheers

Like Ron Elazar likes this
Orit Nachshon
Contributor
July 16, 2018

@Andriy Yakovlev _Atlassian_ 

We have written the same iRule which target only external REST API.

Can you please explain 2nd point i.e  "This is very crucial to make sure that you redirect traffic only from External application (bot), not from the normal user. In another case, you will be break session affinity which leads to different functional and performance problems."

 

In that you mentioned *Not from the normal user* what does it mean? and how do we check this?

 

Thanks,

Sachin

Andriy Yakovlev _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2018

Hi  @Orit Nachshon


Sure, please let me help with this part:

>In that you mentioned *Not from the normal user* what does it mean?

That means, that user sessions should not be part of the redirect config. They should always talk to the same node.

>and how do we check this?

see the section (How you can check that session affinity is fine. ) in the comment above 

Cheers. 

Orit Nachshon
Contributor
July 23, 2018

@Andriy Yakovlev _Atlassian_@Thomas Deiler

This is the iRule we have implemented. Can you please check. it?

 

when
HTTP_REQUEST {
 if

{ !([HTTP::header value Referer] contains "jirapbguat") and ([HTTP::uri] contains "/rest") and ([HTTP::uri] ne "/login.jsp") }

{   node 10.233.128.120 8080  }

}

 

Thanks,
Sachin

0 votes
Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2018

Dear @Jonnada Kiran,

separating REST from 'normal' calls can be done by analyzing the header information of HTTP requests, sent to the load balancer from the network. Everything that carries /rest/api/ in the destination URL is directed to a specific node.

 

As your company has invested in premium product, there should be a comprehensive documentation about F5 traffic balancing. I cannot help further, I am not familiar with this product.

So long

Thomas

Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 15, 2018

@Jonnada Kiran and @Sanu Soman,

keep in mind, that Jira is communicating with itself via REST. So best you do not balance requests from Jira.

Jira will request the F5 from its external network interface and not communicate from localhost to localhost.

This is not valid for Confluence, only Jira.

So long

Thomas 

Andriy Yakovlev _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2018

Hi all, 

To clarify @Thomas Deiler answer:

Everything that carries /rest/api/ in the destination URL is directed to a specific node.

Jira UI operations also use same REST API, so you should be careful here and redirect traffic to specific Node4 only from External application (bot), not from normal user. In another case you will have user session expired all the time. 

There is no single way how you can do this, a couple of options to name:

  •  based on Referer, as suggested in traffic-distribution-with-atlassian-data-center
  • If referrer != app.yourdomain.com and the request ~ /rest:
    If the page requested == /login.jsp:
    Direct traffic to Node 1 or Node 2 or Node 3 //normal traffic
    Else:
    Direct to Node 4 //external REST API traffic
  • Based on SrcIP
  • Based on UserAgent

 

Hope this helps. 

Suggest an answer

Log in or Sign up to answer