How fast am getting my bets placed inplay?

We were all new to Bet Angel once. Ask any question you like here and fellow forum members promise not to laugh. Betfair trading made simple.
Post Reply
pythonic
Posts: 65
Joined: Sun Jul 08, 2018 10:20 pm

I have to admit that I never thought about thread savety of requests.session (or maybe I just assumed requests would be thread save because it says so on the homepage).
I'm just using one thread per order request currently.
Maybe I should look into that as well.
Group1Buff
Posts: 4
Joined: Wed Feb 06, 2019 10:15 am

LinusP wrote:
Fri Feb 01, 2019 6:10 pm
Not entirely true, Betfair allow keep alive sesssions, having a session which is already connected can save a round trip which is huge. I have just completed some work on using connection pools and modifying the underlying socket to make sure it stays open.

This is a good read if you want to understand TCP and IP:

https://hpbn.co/#toc
Very true and of vital importance if you are on the opposite side of the world of the BF servers as I am! BA is essentially unusable for me if I use it from my home connection due to this 'double trip' phenomenon (not savvy enough to explore keeping sockets open etc). When using it through a VPS the effect is greatly mitigated but it still exists but at least it's manageable.

A bet response time would be a very useful metric despite what some other posters have said, particularly for international users.
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

Group1Buff wrote:
Wed Feb 06, 2019 10:28 am
LinusP wrote:
Fri Feb 01, 2019 6:10 pm
Not entirely true, Betfair allow keep alive sesssions, having a session which is already connected can save a round trip which is huge. I have just completed some work on using connection pools and modifying the underlying socket to make sure it stays open.

This is a good read if you want to understand TCP and IP:

https://hpbn.co/#toc
Very true and of vital importance if you are on the opposite side of the world of the BF servers as I am! BA is essentially unusable for me if I use it from my home connection due to this 'double trip' phenomenon (not savvy enough to explore keeping sockets open etc). When using it through a VPS the effect is greatly mitigated but it still exists but at least it's manageable.

A bet response time would be a very useful metric despite what some other posters have said, particularly for international users.
Agreed, it's also two trips if using https.
pythonic
Posts: 65
Joined: Sun Jul 08, 2018 10:20 pm

Based on what I read in the bug reports I think the problems with session and thread safety should only be relevant in certain scenarios where you access lots of different hosts from one Session() btw.
I'll just keep using one session instance for betfair for the time being.
LinusP
Posts: 1871
Joined: Mon Jul 02, 2012 10:45 pm

pythonic wrote:
Thu Feb 07, 2019 8:37 am
Based on what I read in the bug reports I think the problems with session and thread safety should only be relevant in certain scenarios where you access lots of different hosts from one Session() btw.
I'll just keep using one session instance for betfair for the time being.
Not sure how many concurrent requests you make but I get lots of connection errors when trying to use one session, haven't had one since upgrading to multiple sessions and my overall median latency has reduced.
pythonic
Posts: 65
Joined: Sun Jul 08, 2018 10:20 pm

Thats interesting. I get a few connection errors sometimes and wondered why. Note that you can you can modify the maximum pool size of a session to NN like this (default is 10):
self.session = requests.Session()
adapter = requests.adapters.HTTPAdapter(pool_connections=NN, pool_maxsize=NN)
self.session.mount('https://', adapter)
I'll try to increase my pool size and see if the connection errors disappear.
Post Reply

Return to “Bet Angel for newbies / Getting started”