Skip to content

Conversation

@Taishikun0721
Copy link
Owner

@Taishikun0721 Taishikun0721 commented Mar 30, 2021

実施内容

  • sidekiqを導入して、メール送信の非同期処理を永続化した。

動作確認

  • 非同期実行なので、フォローなどを実施した際に、すぐにメールが送信されない事を確認(処理が終わってから、実行される)

  • sleep(5)などを入れて、非同期処理が行われているか確認。

    • perform_now同期的だから、数秒待たされる
    • perform_later非同期的に処理するから、待たされない

その他

  • 実際に使用するユーザーからすると、快適にサービスが使用できるようになるので基本として抑えておく必要がありそう。
  • もうちょっとredisの中身などを見て、遊んでみようと思う

@Taishikun0721 Taishikun0721 changed the title 課題12 sidekiqを導入して 課題12 sidekiqを導入してキューの永続化を実施 Mar 30, 2021
@DaichiSaito
Copy link

sleep(5)などを入れて、非同期処理が行われているか確認。

perform_now同期的だから、数秒待たされる
perform_later非同期的に処理するから、待たされない

こういう検証まじいいですね〜!!

config.time_zone = 'Asia/Tokyo'
config.active_record.default_timezone = :local
config.i18n.default_locale = :ja
# 実際に非同期処理を行うのはsidekiqで、Active_jobはそのインターフェースを準備してるだけなので、ここでは、どの非同期処理ツールを使うか設定している。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1 @@
# 本来なら、ここに本番環境のredis接続先を書かないといけない? No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Comment on lines +66 to +67
また話が逸れるが、スレッドというのは、プログラムの命令の単位の事で、この命令を複数同時に実行する事を
マルチスレッドというらしい。調べたけどほとんどわからなかった。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スレッドの概念は難しすぎて自分も曖昧です。。。

`perform_later`と `perfrom_now`の違いは非同期実行かどうかで、非同期実行とはその場で実行するのではなく、重い処理などを
メソッドが実行された時と別のタイミングで実行する事をいう。[この例をやったらわかりやすかった](https://qiita.com/jnchito/items/3482a30262874b80a8e4)

ただ重い処理を別タイミングで実行したい場合は、大概、 `perform_later`なのかなと思った。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

その認識でOK

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants