WebSockets — Concept Check
Questions on WebSockets. WebSocket provides a full-duplex, persistent connection over a single TCP connection — enabling the server to push data to the client without polling, ideal for chat, live feeds, and collaborative apps.
Questions in this quiz
8 questions on WebSockets — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A real-time chat application uses WebSockets for communication. The server suddenly starts experiencing high memory usage. What could be a likely cause?
- AHigh CPU usage due to encryption
- BToo many open WebSocket connections
- CFrequent HTTP requests instead of WebSocket messages
- DExcessive use of WebSocket over TLS
2.During a WebSocket handshake, what indicates a successful protocol upgrade?
- AHTTP 200 OK response
- BHTTP 500 Internal Server Error response
- CHTTP 404 Not Found response
- DHTTP 101 Switching Protocols response
3.A developer claims WebSockets use a 'request-response' model similar to HTTP. Which option correctly describes WebSockets?
- AWebSockets require frequent polling for updates
- BWebSockets provide a persistent, bidirectional channel
- CWebSockets use a request-response model
- DWebSockets close the connection after each message
4.In a gaming application using WebSockets, players experience delays in updates. What could improve performance?
- AUsing HTTP/2 for WebSocket connections
- BSwitching to non-blocking I/O like Netty
- CIncreasing the number of server threads
- DReducing the number of WebSocket connections
5.A company uses WebSockets over port 80 for a live feed application. What potential issue might they face?
- AHigher latency compared to HTTP
- BLack of encryption for data transmission
- CIncompatibility with HTTP/2
- DInability to handle high traffic
6.A developer suggests using Server-Sent Events (SSE) instead of WebSockets for a chat application. Why might this be a poor choice?
- ASSE only supports unidirectional communication
- BSSE requires more memory per connection
- CSSE scales better than WebSockets
- DSSE connections are always encrypted
7.What is the main advantage of using WebSockets over traditional HTTP for real-time applications?
- ABetter compatibility with browsers
- BPersistent, bidirectional communication
- CSimpler implementation
- DLower initial connection overhead
8.A server handling 10,000 WebSocket connections is experiencing performance issues. What is a recommended approach to address this?
- AImplement a shared pub/sub layer for message routing
- BSwitch to HTTP/1.1 for connections
- CUse a thread-per-connection model
- DLimit the number of concurrent connections