You might not need HTTP

  Рет қаралды 8,868

nixhero

nixhero

Күн бұрын

Пікірлер: 41
@moristar
@moristar 6 ай бұрын
Millennials discovering low-level protocols...
@WildanMubarok
@WildanMubarok 6 ай бұрын
Next: You might not need TCP
@laycookie-f6i
@laycookie-f6i 6 ай бұрын
Last person who said that to me ended up implementing TCP over UDP. This is my highlight of the year lol.
@antonsinitsyn6420
@antonsinitsyn6420 5 ай бұрын
​​@@laycookie-f6iI remember how Siemens made the fastest protocol for their controllers. They just removed some fields from TCP.
@MrYerak5
@MrYerak5 5 ай бұрын
​@@laycookie-f6i why not serial port
@tedchirvasiu
@tedchirvasiu 6 ай бұрын
I don't need HTTP man, I need a girlfriend.
@JB52520
@JB52520 5 ай бұрын
Painfully relatable, but as they say, the grass is always greener. Life gets a lot more complicated when it's you, someone else, and the life you build together. Your time is not your own, and neither are you. It sucks having to constantly earn someone's approval.
@gustavojoaquin_arch
@gustavojoaquin_arch 5 ай бұрын
Same
@NexusGamingRadical
@NexusGamingRadical 6 ай бұрын
At university 3 years ago, I accidently made my first networked app using sockets, not even knowing it wasn't http. Best mistake ever.
@Pismice
@Pismice 5 ай бұрын
You short and very informatives videos deserve waaaay more views, keep it up bro
@odw32
@odw32 5 ай бұрын
The main application where it is advantageous, is a high volume of updates/polling. If you have a hardware device measuring weather (temperature, wind speed), you could set up a HTTP server and do a GET request to a "/metrics" route every 100ms and return a JSON object. Or you could just initiate connections and stream multiple metrics over multiple TCP or even UDP connections (and then pour that data into a time series DB).
@eveykhan
@eveykhan 5 ай бұрын
Do they teach TCP/UDP in college these days? It’s impressive how many new grads I’ve met that only knew about HTTP
@morpheusjones4384
@morpheusjones4384 5 ай бұрын
They do. But the quality of the college program must be taken into account. I've seen community colleges that are well funded produce more educated students in the TCP/IP suite since the curriculum is basically feeding them the Cisco CCNA and CCNP certification courses. The computer science majors typically have to know ABOUT TCP, but not really have a deep understanding of it and working knowledge of it. If I were to ask the average computer science major what is Nagle's algorithm, they would be lost in the conversation.
@ricksegalCanada
@ricksegalCanada 6 ай бұрын
i think you might have set a record of what can be done in under two minutes. super!
@thejezzi5219
@thejezzi5219 5 ай бұрын
Wow Sun Tzu really was ahead of his time :P
@hi_arav
@hi_arav 6 ай бұрын
I love this shortform content. Please make more :D
@TheMeanderingGentleman
@TheMeanderingGentleman 6 ай бұрын
Very high quality video! Nice work!
@RandomGeometryDashStuff
@RandomGeometryDashStuff 6 ай бұрын
01:02 does TCP preserve message start and end? I mean can this happen: server: send "foo" to client send "bar" to client client: receive "foobar"
@chudchadanstud
@chudchadanstud 6 ай бұрын
no what you said can happen. That's why we usually append the message size in front of the messge. You can reserve 8 bytes in front to represent the 64-bit number as the size of the message, or you can add delimiter. The choice is yours. I prefer to do [size: 8bytes][metadata: 8 or 16 bytes, is usually a type id][data]
@clooskey
@clooskey 6 ай бұрын
It's common to process received data byte by byte anyways so you have to implement your own ways of determining the start and end of the message. You have no control over whether your message is sent as one or more TCP packets. Also two or more subsequent "send" calls might be merged into one packet. You can look up Nagle's Algorithm that is responsible for this behaviour. Usually it's also possible to disable it as it causes some delay when it waits for more data to be merged.
@siriusleto3758
@siriusleto3758 5 ай бұрын
In other words, use HTTP or you will have to reinvent the wheel.
@clooskey
@clooskey 5 ай бұрын
@@siriusleto3758 HTTP is not always the answer. All that parsing is relatively easy if you don't go crazy with the complexity of the messages you're sending. HTTP might be too unnecessarily heavy for some applications.
@clooskey
@clooskey 5 ай бұрын
@@siriusleto3758 Most of the industrial stuff (barcode scanners, label printers etc) use simple TCP connections and it's really easy to get working and it just works. They usually use the same frame structure that they used before with the serial interface that had no concept of packets so they are very well designed
@realhuna
@realhuna 6 ай бұрын
umm how u creating those videos like are u getting screenshots or something else?
@abhaysalvi9787
@abhaysalvi9787 6 ай бұрын
Haha, cool content man!
@entertain8648
@entertain8648 6 ай бұрын
Can you explain how much faster this could be Let's say I have a nodejs programm that runs on a VPS, and I send a request (to buy something) to an exchange. I need it to be as fast as possible, so would using TCP instead of default HTTP libs (axios, got) help to reduce latency?
@takivilmos
@takivilmos 6 ай бұрын
I doubt it would be significant, but you would end up spending way too much time to get it correct, and way too painful if you don't. I'd recommend doing it anyway for learning purposes, it will open a world for you once you understand these lower lever stuffs, but don't expose it to the internet. Remember, if it is on the internet, you don't control all the clients trying to connect. Don't even try to calculate the probability of others connecting to your IP to your port, because they 100% will, even if you consider it unlikely. Crawlers exist. A few examples of what you'll need to handle. : - Security(!!!): If you deploy something to your vps, you'll need to handle security/encryption on your own. You can use TLS on top of TCP that will do it for you, but it can be misconfigured, and hacked in very weird and funny ways. HTTPS does so much. - Data size: How big packets will you accept? What happens if the client sends more data than allowed? - Chunking: What happens if your client doesn't send all the data at once? Will you accept multiple packets? You need to handle it, by concating those buffers. It is not that big deal, but if you accept multiple "commands" in one connection, it can get very tricky. - Bigger data sizes: If you have a lot of data, it is bad idea to read them all to an array, and then process them, because it will fill your ram (If you have 10M of data sent, but from 1000 devices, that is 10 G of ram). If you combine it with the previous one, it will get even trickier. - Timing: What happens if the client never finishes the data it tries to send you? Will it just do nothing and sit there? That way it fills your memory, and over time it will be not only 1 client but x > a big number, and it will consume a considerable amount of your server resources simply because they went gone. You need to have timeouts for these connections, which is, again, very tricky. - The protocol itself you'll implement: Now you don't have API routes, you'll have to handle that yourself. Even if you have 2 things you want to do, you'll need to determine which one you currently want, and this adds complexity to your code even more. The only time I can imagine it is worth it is when you send very small data a lot of times. I.e. some gps tracker or something you want to track every second, from 1000 devices. In this scenario it can have some impact, because the HTTP headers are a lot of overhead, but then you'd be better with a language designed for higher performances, and you have to know what you are doing, and in this case you would probably be better without even TCP and using UDP, but that is even more complex.
@7heMech
@7heMech 6 ай бұрын
Firstly I wouldn't use NodeJS, secondly why tf would you use axios/got on the backend, also the server which you are connecting to is likely a web server so you can't use raw TCP.
@entertain8648
@entertain8648 6 ай бұрын
​@@7heMechfrom my testing these libs worked faster than nodejs ways, (by means of cpu, not networking), so I used them. Regarding a possible or not, I think yes, because I saw someone else's implementation in Python. Well, I hope low level socket TCP is gonna be worth it
@7heMech
@7heMech 6 ай бұрын
@@entertain8648 nothing is better than pure node on node itself all those packages use pure node in the background, Python sucks speed-wise and you can't use low level TCP as I said. Based on your knowledge, you'd be better off with BunJS using native fetch.
@Manhunternew
@Manhunternew 6 ай бұрын
If you want it as fast as possible you should place your server next to the exchange server
@OpenSaned
@OpenSaned 6 ай бұрын
Obviously the next step is Pigeons.
@bionic_batman
@bionic_batman 5 ай бұрын
Well, IP over Avian Carriers standard does exist so in theory you can already use pigeons with sockets
@ggsap
@ggsap 5 ай бұрын
"No bloat" Proceeds to use nodejs
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Рет қаралды 225 М.
Python Loops 101: Master For and While Loops (Part 2)
10:03
Digital Dimension
Рет қаралды 101
The day of the sea 😂 #shorts by Leisi Crazy
00:22
Leisi Crazy
Рет қаралды 1,3 МЛН
Шок. Никокадо Авокадо похудел на 110 кг
00:44
How To Get Married:   #short
00:22
Jin and Hattie
Рет қаралды 17 МЛН
Fake watermelon by Secret Vlog
00:16
Secret Vlog
Рет қаралды 16 МЛН
You don't need a frontend framework
15:45
Andrew Schmelyun
Рет қаралды 125 М.
HTTP Polling vs SSE vs WebSocket vs WebHooks
22:22
ByteVigor
Рет қаралды 11 М.
Why WebSockets Are NOT Scalable | WebSockets Explained
12:07
Mehul - Codedamn
Рет қаралды 33 М.
The purest coding style, where bugs are near impossible
10:25
Coderized
Рет қаралды 973 М.
NixOS Virtual machines
43:03
NixOS Discovery
Рет қаралды 1,7 М.
The cloud is over-engineered and overpriced (no music)
14:39
Tom Delalande
Рет қаралды 604 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 337 М.
Making Minimalist Web Server in C on Linux
10:23
Nir Lichtman
Рет қаралды 245 М.
Signals. I spent 2 years to understand this part.
21:24
kimylamp
Рет қаралды 232 М.
Writing My Own Database From Scratch
42:00
Tony Saro
Рет қаралды 225 М.
The day of the sea 😂 #shorts by Leisi Crazy
00:22
Leisi Crazy
Рет қаралды 1,3 МЛН