Proposal: Avoid re-encoding in handle_out when used as a filter

82 views
Skip to first unread message

gfo...@gmail.com

unread,
Mar 4, 2020, 2:30:48 AM3/4/20
to phoenix-core
Hi all, we are running into a performance bottleneck when using "intercept" and "handle_out" in a Phoenix channel.

In our use case, we have subscribers to a topic, but some subscribers have a set of "blocked" and "blocked by" users in their socket.assigns. We use the "handle_out" mechanism to check these maps at intercept time to prevent the message from being delivered to a given blocked receiver. Given that the state involved is only available on the socket of the receiver, we need to use intercept/handle_out. However, we pay a large performance cost, since the outgoing messages are uniquely encoded by Phoenix, despite the fact we are passing them through as-is.

In our case, where handle_out is a pass/fail filter on the message, it seems like there is an optimization opportunity. It would be nice if a facility existed where a intercept could be registered, but the goal of the intercept wasn't to mutate the message, but instead block or pass through the message as-is. This would allow the existing optimization of non-intercepted events to pass through the encoded message, without having to re-encode it.

Ergonomically, this could be done either by keeping the handle_out semantics but providing a new return value which signalled to phoenix that the original encoded payload should be pushed through as-is. Or, a new facility analagous to "handle_out" could be added which is expected to return a value indicating if the message should be passed through (eg "filter_out".) The former seems more in the style of phoenix, but hard to say.

This seems like a really strong optimization, given that a common use-case for handle_out is to perform late filtering on messages based upon things like security, rate limiting, etc, without the need to actually re-encode the message.

Thanks for any interest!

José Valim

unread,
Mar 4, 2020, 3:45:13 AM3/4/20
to phoeni...@googlegroups.com
Hi Greg!

Phoenix master (upcoming v1.5) will use PubSub v2.0 where we have made the dispatching mechanism more flexible. I wonder if you can use the new mechanism instead to provide the flexibility that you need.

In master, when you call Phoenix.Endpoint.broadcast:


It boils down to be a call to Phoenix.PubSub with a custom module:


That has a dispatching function:


The parameters available on dispatching are given on subscription:


This means you could put in a relatively straight-forward fashion setup a separate topic with custom dispatching rules that would also look at conditionals.

Another option is for you to drop channels and work directly with the socket, as can be shown here: https://github.com/phoenixframework/phoenix/blob/29b16e0c3a230fa06aa6386bda9d745d3db3330f/lib/phoenix/socket/transport.ex#L50 - this is available since v1.4.

What do you think about these options?

--
You received this message because you are subscribed to the Google Groups "phoenix-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-core...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-core/0ca75210-7a4d-4394-b6f7-347c5b186f2b%40googlegroups.com.

gfo...@gmail.com

unread,
Mar 4, 2020, 4:10:14 AM3/4/20
to phoenix-core
Thanks for the quick reply José! I will investigate further and let you know how it goes.

Chris McCord

unread,
Mar 4, 2020, 8:34:48 AM3/4/20
to phoeni...@googlegroups.com
Handle_out has a known performance penalty, and this particular usecase is one I give as a reason to *not* use intercept because you can accomplish the same goals without it. Instead, I would pass the list of blocks/filters to the client and have the client do the filtering as they receive messages. You then allow broadcast to reach all subscribers, but skip updating the UI if the message should be dropped. Is this possible on your side?

--
You received this message because you are subscribed to the Google Groups "phoenix-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-core...@googlegroups.com.

Greg Fodor

unread,
Mar 4, 2020, 9:50:06 AM3/4/20
to phoeni...@googlegroups.com
Hey Chris, thanks for the info. For us unfortunately that is probably not possible - the messages involved are being blocked for two reasons:

- the user has been blocked by another user, and we want to ensure they no longer receive messages by the blocking user for privacy reasons. (We could drop as you mention on the client in the other direction so the blocking person does not see the blocked messages in the UI, but not the other way around: the blocked user should no longer have any visibility into the blocker, even w a modified client)

- the client is in a “pause” state where we want to minimize client overhead so do not want to deliver incoming messages to it (in our case, the client is in an iframe on a site and is waiting for the user to optionally activate it, but needs to be connected to the channel for other messages)

A little more context: we are using Phoenix as a message bus for a 3D game, so our message load is fairly high throughout (approx ten tps per user) and the data involved is highly sensitive, such as body language transmitted via VR tracking. So we do start to hit this bottleneck w approx 500 ccu or so. 

One thing that I’d be interested in is if there is a way to selectively “upgrade” a channel to have the intercepts after initially being cheap to send. Most channels connections do not have either blocking state nor are paused, so if we could enter into the intercept state after a block event occurs or the channel is marked as paused by the client that would also solve our problem since that would constitute the vast minority of connections, and eliminate the extra encoding load under high concurrency.

You can try it at hubs.mozilla.com if you want! When you are in a room with someone, hold space and “hide” an avatar - messages between you will be bidirectionally blocked by the server to ensure the (presumed) abuser cannot see your actions in the room.

Hope this helps, and thanks!

You received this message because you are subscribed to a topic in the Google Groups "phoenix-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phoenix-core/BZgJtOE-Q0U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phoenix-core...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-core/91E0F444-B7AB-4F94-9B81-9F2CB3375FAE%40chrismccord.com.

Greg Fodor

unread,
Mar 4, 2020, 10:43:36 AM3/4/20
to phoeni...@googlegroups.com
Actually I may be able to solve the blocking case - I think I can set things up so I alter the event type in the case of a connection involved in a block so it goes down the intercept route, but not otherwise (the client is unchanged.) ie, I stop intercepting event “foo”, and start intercepting event “foo-filtered”, migrate the handle_out to “foo-filtered”, and then on an incoming message if the connection is blocked or has blocks then rewrite the event to “foo-filtered” (and push “foo” in handle_our so the client sees no difference.)

Still need to think about pausing - but that can be solved at a higher level I think - the fact that a topic can be paused or not is known at the topic level for us, and this is rare, so I can probably just have this use the intercept route if and only if the topic is in the special category of being pausable.

Is there a more general way to maybe have a client “opt out” of receiving certain categories of events that don’t involve using handle_out?

Greg Fodor

unread,
Mar 4, 2020, 12:08:10 PM3/4/20
to phoeni...@googlegroups.com
This seems to do the trick - PR is here if you are curious!

 

Greg Fodor

unread,
Mar 4, 2020, 12:58:43 PM3/4/20
to phoeni...@googlegroups.com
looks like this got us a 2x boost before bottleneck moves to cowboy processes :)

on that note (perhaps worthy of another thread) -- is it surprising that we see message backup in the cowboy processes as the final bottleneck (CPU bound) of a high throughput, low subscriber count per topic (~50) phoenix channel? i found it a bit surprising we didn't see the bottleneck ultimately manifest in the JSON encoding/decoding process of moving messages around, but instead it seems like its in the cowboy processes, and my experiments point to TLS (which we have enabled) as the culprit.

i'm still learning how to profile things but I ran a test with TLS disabled and saw a big jump in peak capacity before backup -- any knobs worth turning, compile flags for openssl/otp, cowboy configs, etc? we are on cowboy 1.7 using websockets.

thx again!

Greg Fodor

unread,
Mar 4, 2020, 1:07:25 PM3/4/20
to phoeni...@googlegroups.com
Sorry, cowboy 2.7!

José Valim

unread,
Mar 4, 2020, 1:30:25 PM3/4/20
to phoeni...@googlegroups.com
Unfortunately I do not have a lot of experience on fine tuning SSL. If an option, consider moving SSL to a layer up (a proxy) and see how the whole system compares.

Moto Francis

unread,
Feb 19, 2024, 5:25:27 PMFeb 19
to phoenix-core
SHOP > https://t.me/garminpro12
https://t.me/garminpro12
https://t.me/garminpro12


Buy psychedelic products online

✔US-US Delivery
✔Fast Shipping
✔Secure Payment Options
✔100% Satisfaction Guaranteed
✔3 Days Refund Policy
✔100% Money-Back if any issue with the product
✔Shipping Service: Overnight/Standard/Economy
✔Estimated Delivery Time: Overnight & 3-5 Days
✔Discounts: Get up to 20% off
✔Shipping Rates – USPS: $30 FedEx: $45 Only USA.
✔Pay With Credit / Debit Cards Also
CLICK ➤HERE ➤TO ➤BUY ➤TRAMADOL➤ONLINE

SHOP >> https://t.me/garminpro12
https://t.me/garminpro12
https://t.me/garminpro12
https://t.me/garminpro12
https://t.me/garminpro12
 tramadol-online/

Fedrick Mike

unread,
Mar 13, 2024, 3:13:23 AMMar 13
to phoenix-core

If you're interested in exploring the world of psychedelic mushrooms, you may be wondering if it's possible to buy shrooms online. The good news is that there are many online retailers that offer a wide range of mushroom products, from dried mushrooms to capsules, edibles, and more.
https://t.me/psychedelicmasters/57?single
https://t.me/psychedelicmasters/148?single
https://t.me/psychedelicmasters/128
https://t.me/psychedelicmasters/120
https://t.me/psychedelicmasters/118?single
https://t.me/psychedelicmasters/54
https://t.me/psychedelicmasters/46
https://t.me/psychedelicmasters/16?single
https://t.me/psychedelicmasters/11?single
https://t.me/psychedelicmasters/6
With a large selection of products to meet our clients' demands, Buy Psychedelics Online Shop is your go-to online drug store. We work hard to provide the best Legal Psychedelics For Sale Online and ship our goods internationally from everywhere.
With a large selection of products to meet our clients' demands, Buy Psychedelics Online Shop is your go-to online drug store. We work hard to provide the best Legal Psychedelics For Sale Online and ship our goods internationally from everywhere.

Buy Dmt Online
https://t.me/psychedelicmasters/610
Buy Top Quality Pink Runtz In USA
https://t.me/psychedelicmasters/609
Buy Packwood disposable catrideges Online
Order Big Chief Gummies Online
https://t.me/psychedelicmasters/603
Order Edibles in Europe
https://t.me/psychedelicmasters/598
Buy Gel Tabs Online
https://t.me/psychedelicmasters/596
Buy One Up Psilocybin mushrooms microdose Online
https://t.me/psychedelicmasters/596
https://t.me/psychedelicmasters/593
Buy Percs Online M30
https://t.me/psychedelicmasters/573
Buy XTC Pills Online
https://t.me/psychedelicmasters/571
https://t.me/psychedelicmasters/570
https://t.me/psychedelicmasters/567
Buy Ketamine Online
https://t.me/psychedelicmasters/566
Buy Trippy Flip Chocolate Bars In USA
https://t.me/psychedelicmasters/566
Buy Space Caps Chocolate Bars Online
https://t.me/psychedelicmasters/566
Buy LSD Sheet In USA
https://t.me/psychedelicmasters/560
Buy Trippy Money 500mg Online
https://t.me/psychedelicmasters/560
https://t.me/psychedelicmasters/556
Order LSD Sheet Online
https://t.me/psychedelicmasters/552
https://t.me/psychedelicmasters/548
https://t.me/psychedelicmasters/546
https://t.me/psychedelicmasters/540
Buy Escasy Pills Online
https://t.me/psychedelicmasters/539
https://t.me/psychedelicmasters/53
https://t.me/psychedelicmasters/520
https://t.me/psychedelicmasters/517
https://t.me/psychedelicmasters/501?single
https://t.me/psychedelicmasters/497
Buy Dried Golden Teacher Mushrooms Online
https://t.me/psychedelicmasters/490
https://t.me/psychedelicmasters/487
https://t.me/psychedelicmasters/477
Buy Hash Online
https://t.me/psychedelicmasters/473
https://t.me/psychedelicmasters/471
Buy Stiizy Pods Online
https://t.me/psychedelicmasters/458
https://t.me/psychedelicmasters/456
Buy FRYD Catrideges Online
https://t.me/psychedelicmasters/455
Buy Psilo-Vibin Infused Chocolate bars
https://t.me/psychedelicmasters/455
Buy DMT Powder Online
https://t.me/psychedelicmasters/420
https://t.me/psychedelicmasters/420
Buy Psilocybin Mushroom Sour Gummies Online
https://t.me/psychedelicmasters/420
Buy Wooksauce Rosin Online
https://t.me/psychedelicmasters/415
Buy Polkadot Mushrooms Chocolate bars Online
https://t.me/psychedelicmasters/412
https://t.me/psychedelicmasters/409
https://t.me/psychedelicmasters/407
https://t.me/psychedelicmasters/388
Buy Xannax In USA
https://t.me/psychedelicmasters/388
https://t.me/psychedelicmasters/388
Buy Wonder Bar Online
https://t.me/psychedelicmasters/386
Buy Gold Coast Clear Carts Online
https://t.me/psychedelicmasters/320?single
Buy Gummies Online
https://t.me/psychedelicmasters/275
https://t.me/psychedelicmasters/251
Buy Live Resin Badder Online
https://t.me/psychedelicmasters/217
https://t.me/psychedelicmasters/208?single
https://t.me/psychedelicmasters/206
https://t.me/psychedelicmasters/183?single
https://t.me/psychedelicmasters/128
https://t.me/psychedelicmasters/128
Message has been deleted

Henry Kain

unread,
Apr 27, 2024, 7:40:37 PMApr 27
to phoenix-core
Clone Credit Card💳 orders 📦available
Hi guys tipin with clone cards and get rich today with clones we do have high and low balance content us for more details thanks we do ship through USPS best and fast shipping agency ever 🇱🇷

Clone Credit Card💳 orders 📦available
Hi guys tipin with clone cards and get rich today with clones we do have high and low balance content us for more details thanks we do ship through USPS best and fast shipping agency ever 🇱🇷



Get at me for your low & high balance clone cards going for cool prices. Clone cards are spammed credit cards with clean funds. My clone cards are available for cash out in ATMs🏧,Gas stations⛽️ and can be used for online purchases. Our clone card comes with an ATM pin for easy cash outs ™️
$200 for balance $2k
$400 for balance $5K
$500for balance $7k
$700 for balance $10k

High balance
$1k for balance $15k
$3k for balance $30k
$5k balance $50k
$7k for balance $ 75k


• Shipping 🛫 🛫

• Swift Delivery On DHL & FedEx express

Text me now and make your
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
❗️We have a %100 money back policy . You can opt-out for a refund when you have problems with our cards 💳
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45

Legit clones and CVV:
Clones cards 💳 Available

Low and high balance available and all cards come with pin 📌 GET RICH NOW AND THANK ME LATER
Credit Card Clone Orders 💳 📦 Available Get me for your low and high balance clone cards at a great price. Clone cards are credit cards with clean funds. My clone cards are available for withdrawal at ATMs 🏧, gas stations ⛽️ and can be used for online purchases. Our cloned cards come with an ATM pin for easy withdrawals. How does it work? 💻 💳 Spammers use credit card filters to obtain information from the magnetic stripe of a credit or debit card. The information received is not limited to credit card password, numbers, CVV and expiration date. This information comes in the form of pin dumps (101 or 201), now they use the MSR printer to put the received information on a blank card.

https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
#counterfeit #fakemoney #fakebanknotes #fakenotes #money #fakenote #counterfeitmoney #fakecurrency #fakenotesfordays #bhfyp #counterfeitrock #cash #counterfeitmoneyforsale #fakenotesuk #pounds #fakenotesalready #jamiecampbellbower # #tristanmarmont #fa #fakenotestilyatakenote
CLONE CARD , BANK LOGIN
_________Contact Us________
TELEGRAM CHANNEL :
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Sell Pros + Driving license Info Fullz Any State : New York , California, Alabama, Arizona , California , Colorado , Florida , Georgia , Hawaii, Illinois , Indiana, Kansas, Massachusetts, Michigan ..... Any state in USA
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Sell Info Fullz Company USA Uk Ca Fresh 2021

* Items for sale :

1. USA Fullz ( DOB + SSN) + DL

2. US CC Random

3. EU Random , EU DOB

4. Other Countries (WorldWide)

5. Cash App (Account or Transfer) FLIP

6. Paypals (Verified, Unverified)
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
7. Dumps Track 1/2

Dumps with pin quickest way to get rich. Atm withdrawals In Store purchases. All you need is reader writer. I can supply you work no matter where you are.

Usa, Uk, Canada, China, AU , EU
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Clone card rates

LOW BALANCE
£200 for balance £3k
£300 for balance £4.5k
£400 for balance £6k
£500for balance £8k
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
HIGH BALANCE

£2k for balance £20k
£4k for balance £40k
£5k for balance £60k

Text me now and make your orders right away we are always available anytime you need your package delivered asap guys we good 😊

Telegram link 👇

https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Get at me for your low & high balance clone cards going for cool prices. Clone cards are spammed credit cards with clean funds. My clone cards are available for cash out in ATMs🏧,Gas stations⛽️ and can be used for online purchases. Our clone card comes with an ATM pin for easy cash outs ™️
$200 for balance $2k
$400 for balance $5K
$500for balance $7k
$700 for balance $10k

High balance
$1k for balance $15k
$3k for balance $30k
$5k balance $50k
$7k for balance $ 75k


• Shipping 🛫 🛫

• Swift Delivery On DHL & FedEx express

Text me now and make your
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
❗️We have a %100 money back policy . You can opt-out for a refund when you have problems with our cards 💳
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45

Legit clones and CVV:
Clones cards 💳 Available

Low and high balance available and all cards come with pin 📌 GET RICH NOW AND THANK ME LATER
Credit Card Clone Orders 💳 📦 Available Get me for your low and high balance clone cards at a great price. Clone cards are credit cards with clean funds. My clone cards are available for withdrawal at ATMs 🏧, gas stations ⛽️ and can be used for online purchases. Our cloned cards come with an ATM pin for easy withdrawals. How does it work? 💻 💳 Spammers use credit card filters to obtain information from the magnetic stripe of a credit or debit card. The information received is not limited to credit card password, numbers, CVV and expiration date. This information comes in the form of pin dumps (101 or 201), now they use the MSR printer to put the received information on a blank card.

https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
#counterfeit #fakemoney #fakebanknotes #fakenotes #money #fakenote #counterfeitmoney #fakecurrency #fakenotesfordays #bhfyp #counterfeitrock #cash #counterfeitmoneyforsale #fakenotesuk #pounds #fakenotesalready #jamiecampbellbower # #tristanmarmont #fa #fakenotestilyatakenote
CLONE CARD , BANK LOGIN
_________Contact Us________
TELEGRAM CHANNEL :
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Sell Pros + Driving license Info Fullz Any State : New York , California, Alabama, Arizona , California , Colorado , Florida , Georgia , Hawaii, Illinois , Indiana, Kansas, Massachusetts, Michigan ..... Any state in USA
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Sell Info Fullz Company USA Uk Ca Fresh 2021

* Items for sale :

1. USA Fullz ( DOB + SSN) + DL

2. US CC Random

3. EU Random , EU DOB

4. Other Countries (WorldWide)

5. Cash App (Account or Transfer) FLIP

6. Paypals (Verified, Unverified)
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
7. Dumps Track 1/2

Dumps with pin quickest way to get rich. Atm withdrawals In Store purchases. All you need is reader writer. I can supply you work no matter where you are.

Usa, Uk, Canada, China, AU , EU
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
Clone card rates

LOW BALANCE
£200 for balance £3k
£300 for balance £4.5k
£400 for balance £6k
£500for balance £8k
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
HIGH BALANCE

£2k for balance £20k
£4k for balance £40k
£5k for balance £60k

Text me now and make your orders right away
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45
https://t.me/henrykain45

SUSIANTI

unread,
May 12, 2024, 3:41:45 PMMay 12
to phoenix-core
### SERIOUS FRAUD ###

ICQ: 6060222 ( Tony ) - Working 24/7
Telegram: https://t.me/vendorvuggs1 @vendorvuggs1( Tony ) - Working 24/7
Whatsapp +1‪(636) 851-9306

Telegram: @Henrykain457( Henry )

I paid this scammer $2,282 for a 15k card transaction but he is busy running away from me.
Don't do deal with this Muslim scammer.


Tony and Henry are the same con artists and look at his picture.
Henry Kain_Scammer.jpeg
Reply all
Reply to author
Forward
0 new messages