pssst... I'm using Go in my side project now
ฝัง
- เผยแพร่เมื่อ 26 ก.ย. 2024
- Become a YT Members to get extra perks!
www.youtube.co...
My Products
💀 Scary Story Generator: scarystorygene...
🏗️ WDC StarterKit: wdcstarterkit.com
📖 ProjectPlannerAI: projectplanner...
🤖 IconGeneratorAI: icongeneratora...
Useful Links
💬 Discord: / discord
🔔 Newsletter: newsletter.web...
📁 GitHub: github.com/web...
📺 Twitch: / webdevcody
🤖 Website: webdevcody.com
🐦 Twitter: / webdevcody
These are my favorite types of videos. I love hearing the design decisions and justifications on why someone picked something.
Great job Cody
Some of the main things that will cost you money… is a wife lol it’s me, hi, I’m the problem it’s me. Lol love you babe! You’re doing a great job
He’s switching to Golang to save costs, but still keeping the premium Wife plan. Must be worth every penny!
Great video. Nice to see you come back to GO. It’s very efficient for such backend work.
It's important to note that you have to make sure ressources have unique ids because there is no way to invalidate cloudflare cache afaik
set your proxy so it only only accepts requests through the cloudflare cdn , either directly in the proxy code or through the server firewall if the cdn has a static dns entry you can take advantage of
I could probably just setup a firewall on the docker image itself
I've watched a lot of your content, this is exactly what i expect a good engineer to share, youve looked at tech with your own initiative and shared the knowledge with everyone. Very much appreciated. Thank you
To avoid ddos on the go proxy you can block direct ip access over http to your server. I remember it being an option for a wordpress website with cloudflare so there has to be a way to do it outsided of wordpress too.
@@alessioragonesi8549 I think I could only allow cloudflare ip address as well
so what is the go proxy actually doing?
I’m not sure
from my understanding from the video, wasn't he using the proxy to route client requests to the db?
same here i didn't get it too
The proxy is just being used as a way to request files from the DB without having direct frontend => DB requests
I think just to save bandwidth streaming those videos with js is expensive
good job mate, love it
This is peak, “I built because I could not because I should.”
Isn’t it fun?!
Thanks for you videos!
It would be great so know how you organise your various services and any config in github repos. Is this a monorepo?
noice good to see you back using go hahaha
this is great.. I always wonder about this... fantastic.. do you have a video on how to deploy such setup?
6:23 "yoo-id" 💀
yoooooouuuuuuu-id
Imagine cody as your Project Manager.
From now on, I am a Cody disciple
Are you using the UI with a docker image? In my experience, if you dockerize your next app, it brings down the memory usage to somewhere around 80-120MBs atleast in my case, thought it would be usefull
Yes I am
@@WebDevCody the node:alpine image or the other one? The alpine one is the one that I used
When hosting nextjs on Railway, does it basically just run on a long-running express server?
yes, it's a stateful container
Hi, why didn't you use something like nginx? Is it because you are using convex?
I need to hit an endpoint to convert an id. I don’t think nginx can run logic? I can also potentially add auth checks in the proxy if I want
Why not just have cloudflare cdn in front of convex static asset urls?
because I wasn't sure if someone would be able to figure out my convex project id via websocket events and then by pass cloudflare directly to hit my convex.cloud url directly. that did cross my mind, convex has the ability to setup custom domains, so technically I could just point cloudflare to convex via a domain, I just went with this approach first and didn't think too hard about it.
Hi Cody. I think you could do better by not reading all the file content in one shot. I see that you are using ReadAll. There are maybe better ways to stream that with i think a tee in go. cant remember what is called but it allows you to tie one buffer and reader and let the magic happen. I will look it up and see if i can find it
th-cam.com/video/8z6okCgdREo/w-d-xo.html
this is a great talk about many details in how to build a proxy in go. so io.Copy should do what you want. if you need to do more processing `io.TeeReader` will do what you want if you need more complicated logic
So next.js wasn't just able to handle ur requests without consuming lots of bandwidth? So you added go backend to do the video requesting?
For heavy loads its always recommended to have seperate backend.
I'm not too sure what was going on. There was two things I needed to debug. Was it the tunnel causing issues, was it next.js, or was it my javascript implementation. Overall I decided to instead just use a simple go proxy since I knew it would use little memory and run fast.
Always feels wrong to press like if the like count is 69... but great information as always.
You dirty dog you
where can you learn this stuff?
❤❤
bro can't make his mind
Yes he s all around once he says one thing than he contradicts himself so often can’t trust him for sure
@@Alex-bc3xe Because smart people are always learning and when confronted with something that challenges their current conception are not only willing but happy to change their mind and embrace new information if it benefits them, their project or their users. And yes, if you can't read between the lines, I am suggesting that you two might not be smart people.
what's there to trust? I said in my previous videos Go is good solution for an api; I'm using it for an api proxy.
Has somebody already found out the ip of the go proxy?
@@davidsiewert8649 127.0.0.1
You're calling go proxy instead of cloudflare and getting files from cloudflare for a hit, how? Shouldn't u make request to the cloudflare?
The diagram shows ui makes a request to cloudflare, cloudflare hits proxy, proxy hits
File storage
@@WebDevCody How do you tell cloudflare to go to the proxy? I am new to this
@@adrian110288 cloudflare is also a proxy, so it’ll route requests using a cname record
First!
SECOND!
basically free .... until they decide to shutdown your app 🤣🤣🤣
live on the edge
Hi Cody, I was wondering why do you need the proxy. Is it because you can't send a request directly from cloudflare to convex?
Also, pretty cool video. I really like seeing this kind of system design videos that are not only explain the parts of the system but rather contextualize in a real project how they work.
I think the issue is that if someone knows my convex project id, they could potentially hit my convex http endpoint directly to download files and bypass cloudflare which would mean a larger bandwidth charge. I wasn’t sure if that project id was exposed anywhere in when someone loads up the convex client and starts sending web socket events. Basically I abstracted convex away from the user entirely in regards to files to keep all that hidden. Nothing can download files from convex except my go proxy.
Maybe it’s over engineering, but I don’t want a silly ddos from a yt hater to run up my bill.
@@WebDevCody That makes sense, thanks for explaning that. It's sad you gotta worry about that stuff because of haters but I guess it makes you think more about security, which makes your project more "professional" if you will.
Doesn’t cloudflare frown on using the cdn for videos?
I can’t find where they say that
@@WebDevCody They emphasize multiple times that you shouldn’t serve most of your video cache. Content like HTML, JS, and CSS is acceptable, but for videos, they recommend using Cloudflare Streaming. You can find more information in Cloudflare's Terms of Service and forums. That’s my two cents!
Actually was load testing railway the other day it seems to not like sending images or videos from next apps i was getting horrid performance. This seems like a decent solution
@@Oldbettie yeah idk why, something is fishy about it. Were you using a tunnel?
Hey Cody
I am not 100% sure about this but a while ago I saw an article that you can’t cache user generated assets on cloud flare and you need to use their service R2.
I don’t know if this applies in your case but just to let you know that it can be against their terms of service
I'd be curious if you can find that article. Claude AI is saying caching dynamic or user generated content is allowed as along is it isn't illegal or copy written assets. The article needs to link directly to the cloudflare terms of service or else it's just hearsay imo, but it's always good to double check these things.
@@WebDevCodyok i think my comment was deleted because i added a link but basically this is from their website
Unless you are an Enterprise customer, Cloudflare offers specific Paid Services (e.g., the Developer Platform, Images, and Stream) that you must use in order to serve video and other large files via the CDN
It's in their terms of service. Html only in the cache, unless you use a paid service (like r2). Yet, html isn't cached by default and scripts (and I think images) are...