Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created July 2, 2022 08:00
Show Gist options
  • Save halitbatur/913afa58b25b2858eb0c93e7504c2cc3 to your computer and use it in GitHub Desktop.
Save halitbatur/913afa58b25b2858eb0c93e7504c2cc3 to your computer and use it in GitHub Desktop.
Redis, Cron and Design pattern discussion

Redis, Websockets and cron Discussion

Write your answers in the comment section below:

  • What is Redis? Mention one use case of Redis.
  • What type of database is Redis and where does it hold its data?
  • What is Websocket and what is it used for?
  • Explain 3 use cases for CRON jobs.
  • What are the 3 types of design patterns in Nodejs?
@irem-kurt
Copy link

@huzeyfe0
Copy link

huzeyfe0 commented Jul 2, 2022

Nilay-Ezgi-Huzeyfe
What is Redis? Mention one use case of Redis.
Redis is an open-source, in-memory data structure store used as a database, cache, and message broker.

What type of database is Redis and where does it hold its data?
It is a NoSQL advanced key-value data store, and is often referred to as a data structure server because its keys contain strings, hashes, lists, sets, sorted sets, bitmaps, and hyperloglogs. Redis’ read and write operations are very fast because it stores data in memory. Data can also be stored on the disk or written back to the memory.
Since Redis stores its data in memory, it is most commonly used as a cache.

What is Websocket and what is it used for?
The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

Explain 3 use cases for CRON jobs.
Job: a unit of work, a series of steps to do something. For example, sending an email to a group of users. This article will use task, job, cron job, or event interchangeably.
Daemon: a computer program that runs in the background, serving different purposes. Daemons often start at boot time. A web server is a daemon serving HTTP requests. Cron is a daemon for running scheduled tasks.
Cron Job: a cron job is a scheduled job. The daemon runs the job when it’s due.
Webcron: a time-based job scheduler that runs within the server environment. It’s an alternative to the standard Cron, often on shared web hosts that do not provide shell access.

  • For weekly or monthly subscription services, handle order cutoffs, weekly billing, etc.
  • Syncing data into third party integrations periodically, like email marketing systems
  • Running database cleanup or alert scripts

What are the 3 types of design patterns in Nodejs?
Creational - the creation of the object instances
Structural - the way the objects are designed
Behavioural - how objects interact with each other

@cbaksakal
Copy link

Team: Melek, Mehmet, Cengiz

1. What is Redis? Mention one use case of Redis.

Redis ( Remote Dictionary Server)[]](https://en.wikipedia.org/wiki/Redis#cite_note-RedisFAQ-5) is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability.

Redis is a data structures server. It runs in memory and you can communicate with it over the network thanks to the Redis protocol.
It shines when you want to use data structures such as sets, lists or hashes in a distributed program, be it across different machines or processes in the same machine.
Redis can also do other things such as publish/subscribe.
There are lots of use cases for such a piece of software. Here are a few typical ones in the context of a complex Web application:

  • storing user session data;
  • caching things like user feeds (timelines);
  • implementing rate-limiting;
  • implementing a URL shortener.

2. What type of database is Redis and where does it hold its data?

Redis is a data structure store that can be used as a database, cache, or even a message broker. The storage structure is both open-source and in-memory. It is also NoSQL-based. This means it allows data structures like strings, hashes, lists, sets, sorted sets of data, bit maps, and so on
All Redis data resides in memory, which enables low latency and high throughput data access. Unlike traditional databases, In-memory data stores don't require a trip to disk, reducing engine latency to microseconds.

3. What is Websocket and what is it used for?

The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

  • Social feeds
  • Multiplayer games
  • Collaborative editing/coding

4. Explain 3 use cases for CRON jobs.

  • to send a newsletter (I prepare whenever and send it on following monday) [every week]
  • to monitor the status of the server and services [every 10min]
  • backup personal data to backblaze [every week]
  • dump databse of every website [every day]

5. What are the 3 types of design patterns in Nodejs?

  • Creational - the creation of the object instances
  • Structural - the way the objects are designed
  • Behavioural - how objects interact with each other

  • Factory method pattern
  • Singleton
  • Observer pattern

@khaldarov
Copy link

Rasha, Rama Alshaban, Hamza Aymen, Adnan Khaldar

Redis, Websockets and CRON Discussion

What is Redis? Mention one use case of Redis.

Redis, stands for Remote Dictionary Server, is a fast, open source, in-memory, key-value data store.
Redis enables you to write traditionally complex code with fewer, simpler lines. With Redis, you write fewer lines of code to store, access, and use data in your applications. The difference is that developers who use Redis can use a simple command structure, as opposed to the query languages of traditional databases.

What type of database is Redis, and where does it hold its data?

Redis is a type of database that's commonly referred to as NoSQL or non-relational, there are no tables, and there's no database-defined, or -enforced, way of relating data in Redis with other data in Redis, and it holds the data in the memory of the computer.

What is WebSocket, and what is it used for?

WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection.
In simpler terms, WebSocket enables simultaneous sending and receiving of messages by both client and server. It means that once an initial connection is established, the server can also push messages to the client.
Most browsers support the protocol, including Google Chrome, Firefox, Microsoft Edge, Internet Explorer, Safari and Opera.

Explain 3 use cases for CRON jobs.

A cron job is a Linux command used for scheduling tasks to be executed sometime in the future.

  • Sending emails,
  • Making calls,
  • Downloading from the internet.

What are the 3 types of design patterns in NodeJS?

Design patterns allow us to reuse code for recurrent problems. Reusable solution to a commonly occurring problem.
There are three types of design patterns:

Creational Pattern:

Is the creation of the object instances

Structural Pattern:

Is the way the objects are designed

Behavioral Pattern:

Is how objects interact with each other

Sauces:

https://bettersoftwarewithsid.com/websocket-an-in-depth-beginners-guide
https://en.wikipedia.org/wiki/WebSocket
https://en.wikipedia.org/wiki/Redis
https://en.wikipedia.org/wiki/Cron
https://www.hivelocity.net/

@yamanrajab90
Copy link

Team Members: Israa, Hala, Yaman.

What is Redis? Mention one use case of Redis.
Redis is an open-source key-value database. Data in a key-value database has two parts: the key and the value. Because Redis can accept keys in a wide range of formats,
Cashing is the most popular use case for Redis.
What type of database is Redis and where does it hold its data?
Redis is a NoSQL database, it stores data on the computer’s random access memory (RAM) instead of writing it to a hard disk
What is Websocket and what is it used for?
WebSocket is bidirectional, a full-duplex protocol that is used in the same scenario of client-server communication, unlike HTTP it starts from ws:// or wss://. It is a stateful protocol, which means the connection between client and server will keep alive until it is terminated by either party (client or server)
Explain 3 use cases for CRON jobs.
CRON stands for Command Run On (UNIX scheduler)
The cron command-line utility is a job scheduler on Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs, also known as cron jobs, to run periodically at fixed times, dates, or intervals
The general purpose of Cron is to automate repetitive tasks,
-To send a newsletter (schedule sending newsletter )
-To monitor the status of the server and services.
-backup personal data. (e.g.Whatsapp chat backup)
What are the 3 types of design patterns in Nodejs?

Creational - the creation of the object instances
Structural - the way the objects are designed
Behavioural - how objects interact with each other

@awiednoor
Copy link

awiednoor commented Jul 2, 2022

Abdul Hafiz, Amjad AlKhatib, Noor Awied

What is Redis? Mention one use case of Redis.

Redis is an open source key-value database. Data in a key-value database has two parts: the key and the value. Because Redis can accept keys in a wide range of formats, operations can be executed on the server and reduce the client's workload. Redis is often used for cache management and speeding up web applications.
holds its database entirely in memory

What type of database is Redis and where does it hold its data?

Redis is a Cache, it is more of a volatile and an in Memory database. The data is stored in Key-Value pairs, it’s commonly referred to as a data structure server.
Common use cases:
Cache, Publish and Subscribe, Queues, Counters

What is Websocket and what is it used for?

The WebSocket API is an advanced technology that makes it possible to open a
two-way interactive communication session between the user's browser and a
server. With this API, you can send messages to a server and receive
event-driven responses without having to poll the server for a reply.
WebSocket is bidirectional, a full-duplex protocol that is used in the samescenario of client-server communication, unlike HTTP it starts from ws:// or wss://. It is a stateful protocol, which means the connection between client and server will keep alive until it is terminated by either party (client or server). After closing the connection by either of the client and server, the connection is terminated from both ends.

Explain 3 use cases for CRON jobs.

cron is a Linux utility that schedules a command or script on your server to run automatically at a specified time and date. A cron job is the scheduled task itself.
If you have a membership site, where accounts have expiration dates, you can schedule cron jobs to regularly deactivate or delete accounts that are past their expiration dates.
You can send out daily newsletter e-mails.
If you have summary tables (or materialized views) in your database, they can be regularly updated with a cron job. For example you may store every web page hit in a table, but another summary table may contain daily traffic summaries.

What are the 3 types of design patterns in Nodejs?

Creational - the creation of the object instances
Structural - the way the objects are designed
Behavioural - how objects interact with each other

References:

https://www.geeksforgeeks.org/what-is-web-socket-and-how-it-is-different-from-the-http/
https://www.credera.com/insights/redis-explained-5-minutes-less
https://www.hostgator.com/help/article/what-are-cron-jobs
https://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API

@dilarafirtina
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment